aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/dvm/testmode.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/dvm/testmode.c')
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/testmode.c1113
1 files changed, 1113 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwlwifi/dvm/testmode.c b/drivers/net/wireless/iwlwifi/dvm/testmode.c
new file mode 100644
index 00000000000..59cfe9a8eea
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/dvm/testmode.c
@@ -0,0 +1,1113 @@
1/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2010 - 2012 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
63#include <linux/init.h>
64#include <linux/kernel.h>
65#include <linux/module.h>
66#include <linux/dma-mapping.h>
67#include <net/net_namespace.h>
68#include <linux/netdevice.h>
69#include <net/cfg80211.h>
70#include <net/mac80211.h>
71#include <net/netlink.h>
72#include "iwl-debug.h"
73#include "iwl-io.h"
74#include "iwl-trans.h"
75#include "iwl-fh.h"
76#include "iwl-prph.h"
77#include "dev.h"
78#include "agn.h"
79#include "testmode.h"
80
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 */
93static
94struct 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
107 [IWL_TM_ATTR_EEPROM] = { .type = NLA_UNSPEC, },
108
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 */
134static inline int get_event_length(struct iwl_rx_cmd_buffer *rxb)
135{
136 struct iwl_rx_packet *pkt = rxb_addr(rxb);
137 if (pkt)
138 return le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
139 else
140 return 0;
141}
142
143
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
164static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv,
165 struct iwl_rx_cmd_buffer *rxb)
166{
167 struct ieee80211_hw *hw = priv->hw;
168 struct sk_buff *skb;
169 void *data;
170 int length;
171
172 data = (void *)rxb_addr(rxb);
173 length = get_event_length(rxb);
174
175 if (!data || length == 0)
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
192nla_put_failure:
193 kfree_skb(skb);
194 IWL_ERR(priv, "Ouch, overran buffer, check allocation!\n");
195}
196
197void iwl_testmode_init(struct iwl_priv *priv)
198{
199 priv->pre_rx_handler = NULL;
200 priv->testmode_trace.trace_enabled = false;
201 priv->testmode_mem.read_in_progress = false;
202}
203
204static void iwl_mem_cleanup(struct iwl_priv *priv)
205{
206 if (priv->testmode_mem.read_in_progress) {
207 kfree(priv->testmode_mem.buff_addr);
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}
214
215static void iwl_trace_cleanup(struct iwl_priv *priv)
216{
217 if (priv->testmode_trace.trace_enabled) {
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}
232
233
234void iwl_testmode_cleanup(struct iwl_priv *priv)
235{
236 iwl_trace_cleanup(priv);
237 iwl_mem_cleanup(priv);
238}
239
240
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 */
257static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
258{
259 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
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
321nla_put_failure:
322 IWL_DEBUG_INFO(priv, "Failed creating NL attributes\n");
323 return -ENOMSG;
324}
325
326
327/*
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 */
344static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb)
345{
346 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
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
415nla_put_failure:
416 kfree_skb(skb);
417 return -EMSGSIZE;
418}
419
420
421static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv)
422{
423 struct iwl_notification_wait calib_wait;
424 static const u8 calib_complete[] = {
425 CALIBRATION_COMPLETE_NOTIFICATION
426 };
427 int ret;
428
429 iwl_init_notification_wait(&priv->notif_wait, &calib_wait,
430 calib_complete, ARRAY_SIZE(calib_complete),
431 NULL, NULL);
432 ret = iwl_init_alive_start(priv);
433 if (ret) {
434 IWL_ERR(priv, "Fail init calibration: %d\n", ret);
435 goto cfg_init_calib_error;
436 }
437
438 ret = iwl_wait_notification(&priv->notif_wait, &calib_wait, 2 * HZ);
439 if (ret)
440 IWL_ERR(priv, "Error detecting"
441 " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret);
442 return ret;
443
444cfg_init_calib_error:
445 iwl_remove_notification(&priv->notif_wait, &calib_wait);
446 return ret;
447}
448
449/*
450 * This function handles the user application commands for driver.
451 *
452 * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the
453 * handlers respectively.
454 *
455 * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned
456 * value of the actual command execution is replied to the user application.
457 *
458 * If there's any message responding to the user space, IWL_TM_ATTR_SYNC_RSP
459 * is used for carry the message while IWL_TM_ATTR_COMMAND must set to
460 * IWL_TM_CMD_DEV2APP_SYNC_RSP.
461 *
462 * @hw: ieee80211_hw object that represents the device
463 * @tb: gnl message fields from the user space
464 */
465static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
466{
467 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
468 struct iwl_trans *trans = priv->trans;
469 struct sk_buff *skb;
470 unsigned char *rsp_data_ptr = NULL;
471 int status = 0, rsp_data_len = 0;
472 u32 devid, inst_size = 0, data_size = 0;
473 const struct fw_img *img;
474
475 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
476 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME:
477 rsp_data_ptr = (unsigned char *)priv->cfg->name;
478 rsp_data_len = strlen(priv->cfg->name);
479 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
480 rsp_data_len + 20);
481 if (!skb) {
482 IWL_ERR(priv, "Memory allocation fail\n");
483 return -ENOMEM;
484 }
485 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,
486 IWL_TM_CMD_DEV2APP_SYNC_RSP) ||
487 nla_put(skb, IWL_TM_ATTR_SYNC_RSP,
488 rsp_data_len, rsp_data_ptr))
489 goto nla_put_failure;
490 status = cfg80211_testmode_reply(skb);
491 if (status < 0)
492 IWL_ERR(priv, "Error sending msg : %d\n", status);
493 break;
494
495 case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW:
496 status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_INIT);
497 if (status)
498 IWL_ERR(priv, "Error loading init ucode: %d\n", status);
499 break;
500
501 case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB:
502 iwl_testmode_cfg_init_calib(priv);
503 priv->ucode_loaded = false;
504 iwl_trans_stop_device(trans);
505 break;
506
507 case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW:
508 status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR);
509 if (status) {
510 IWL_ERR(priv,
511 "Error loading runtime ucode: %d\n", status);
512 break;
513 }
514 status = iwl_alive_start(priv);
515 if (status)
516 IWL_ERR(priv,
517 "Error starting the device: %d\n", status);
518 break;
519
520 case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW:
521 iwl_scan_cancel_timeout(priv, 200);
522 priv->ucode_loaded = false;
523 iwl_trans_stop_device(trans);
524 status = iwl_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN);
525 if (status) {
526 IWL_ERR(priv,
527 "Error loading WOWLAN ucode: %d\n", status);
528 break;
529 }
530 status = iwl_alive_start(priv);
531 if (status)
532 IWL_ERR(priv,
533 "Error starting the device: %d\n", status);
534 break;
535
536 case IWL_TM_CMD_APP2DEV_GET_EEPROM:
537 if (priv->eeprom) {
538 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
539 priv->cfg->base_params->eeprom_size + 20);
540 if (!skb) {
541 IWL_ERR(priv, "Memory allocation fail\n");
542 return -ENOMEM;
543 }
544 if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND,
545 IWL_TM_CMD_DEV2APP_EEPROM_RSP) ||
546 nla_put(skb, IWL_TM_ATTR_EEPROM,
547 priv->cfg->base_params->eeprom_size,
548 priv->eeprom))
549 goto nla_put_failure;
550 status = cfg80211_testmode_reply(skb);
551 if (status < 0)
552 IWL_ERR(priv, "Error sending msg : %d\n",
553 status);
554 } else
555 return -EFAULT;
556 break;
557
558 case IWL_TM_CMD_APP2DEV_FIXRATE_REQ:
559 if (!tb[IWL_TM_ATTR_FIXRATE]) {
560 IWL_ERR(priv, "Missing fixrate setting\n");
561 return -ENOMSG;
562 }
563 priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]);
564 break;
565
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:
600 skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8);
601 if (!skb) {
602 IWL_ERR(priv, "Memory allocation fail\n");
603 return -ENOMEM;
604 }
605 if (!priv->ucode_loaded) {
606 IWL_ERR(priv, "No uCode has not been loaded\n");
607 return -EINVAL;
608 } else {
609 img = &priv->fw->img[priv->cur_ucode];
610 inst_size = img->sec[IWL_UCODE_SECTION_INST].len;
611 data_size = img->sec[IWL_UCODE_SECTION_DATA].len;
612 }
613 if (nla_put_u32(skb, IWL_TM_ATTR_FW_TYPE, priv->cur_ucode) ||
614 nla_put_u32(skb, IWL_TM_ATTR_FW_INST_SIZE, inst_size) ||
615 nla_put_u32(skb, IWL_TM_ATTR_FW_DATA_SIZE, data_size))
616 goto nla_put_failure;
617 status = cfg80211_testmode_reply(skb);
618 if (status < 0)
619 IWL_ERR(priv, "Error sending msg : %d\n", status);
620 break;
621
622 default:
623 IWL_ERR(priv, "Unknown testmode driver command ID\n");
624 return -ENOSYS;
625 }
626 return status;
627
628nla_put_failure:
629 kfree_skb(skb);
630 return -EMSGSIZE;
631}
632
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 */
646static 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
712nla_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
720static 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/*
753 * This function handles the user application switch ucode ownership.
754 *
755 * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_OWNER and
756 * decide who the current owner of the uCode
757 *
758 * If the current owner is OWNERSHIP_TM, then the only host command
759 * can deliver to uCode is from testmode, all the other host commands
760 * will dropped.
761 *
762 * default driver is the owner of uCode in normal operational mode
763 *
764 * @hw: ieee80211_hw object that represents the device
765 * @tb: gnl message fields from the user space
766 */
767static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb)
768{
769 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
770 u8 owner;
771
772 if (!tb[IWL_TM_ATTR_UCODE_OWNER]) {
773 IWL_ERR(priv, "Missing ucode owner\n");
774 return -ENOMSG;
775 }
776
777 owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]);
778 if (owner == IWL_OWNERSHIP_DRIVER) {
779 priv->ucode_owner = owner;
780 priv->pre_rx_handler = NULL;
781 } else if (owner == IWL_OWNERSHIP_TM) {
782 priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt;
783 priv->ucode_owner = owner;
784 } else {
785 IWL_ERR(priv, "Invalid owner\n");
786 return -EINVAL;
787 }
788 return 0;
789}
790
791static 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
830static 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 */
884static 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
917static 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
950static 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
966 * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then
967 * invoke the corresponding handlers.
968 *
969 * This function is invoked when there is user space application sending
970 * gnl message through the testmode tunnel NL80211_CMD_TESTMODE regulated
971 * by nl80211.
972 *
973 * It retrieves the mandatory field, IWL_TM_ATTR_COMMAND, before
974 * dispatching it to the corresponding handler.
975 *
976 * If IWL_TM_ATTR_COMMAND is missing, -ENOMSG is replied to user application;
977 * -ENOSYS is replied to the user application if the command is unknown;
978 * Otherwise, the command is dispatched to the respective handler.
979 *
980 * @hw: ieee80211_hw object that represents the device
981 * @data: pointer to user space message
982 * @len: length in byte of @data
983 */
984int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
985{
986 struct nlattr *tb[IWL_TM_ATTR_MAX];
987 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
988 int result;
989
990 result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len,
991 iwl_testmode_gnl_msg_policy);
992 if (result != 0) {
993 IWL_ERR(priv, "Error parsing the gnl message : %d\n", result);
994 return result;
995 }
996
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 */
1003 mutex_lock(&priv->mutex);
1004
1005 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
1006 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:
1011 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32:
1012 case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
1013 IWL_DEBUG_INFO(priv, "testmode cmd to register\n");
1014 result = iwl_testmode_reg(hw, tb);
1015 break;
1016 case IWL_TM_CMD_APP2DEV_GET_DEVICENAME:
1017 case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW:
1018 case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB:
1019 case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW:
1020 case IWL_TM_CMD_APP2DEV_GET_EEPROM:
1021 case IWL_TM_CMD_APP2DEV_FIXRATE_REQ:
1022 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:
1026 IWL_DEBUG_INFO(priv, "testmode cmd to driver\n");
1027 result = iwl_testmode_driver(hw, tb);
1028 break;
1029
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:
1038 IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n");
1039 result = iwl_testmode_ownership(hw, tb);
1040 break;
1041
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:
1056 IWL_ERR(priv, "Unknown testmode command\n");
1057 result = -ENOSYS;
1058 break;
1059 }
1060
1061 mutex_unlock(&priv->mutex);
1062 return result;
1063}
1064
1065int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
1066 struct netlink_callback *cb,
1067 void *data, int len)
1068{
1069 struct nlattr *tb[IWL_TM_ATTR_MAX];
1070 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
1071 int result;
1072 u32 cmd;
1073
1074 if (cb->args[3]) {
1075 /* offset by 1 since commands start at 0 */
1076 cmd = cb->args[3] - 1;
1077 } else {
1078 result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len,
1079 iwl_testmode_gnl_msg_policy);
1080 if (result) {
1081 IWL_ERR(priv,
1082 "Error parsing the gnl message : %d\n", result);
1083 return result;
1084 }
1085
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]);
1092 cb->args[3] = cmd + 1;
1093 }
1094
1095 /* in case multiple accesses to the device happens */
1096 mutex_lock(&priv->mutex);
1097 switch (cmd) {
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);
1112 return result;
1113}