iwl-testmode.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  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-wifi.h"
  73. #include "iwl-dev.h"
  74. #include "iwl-core.h"
  75. #include "iwl-debug.h"
  76. #include "iwl-io.h"
  77. #include "iwl-agn.h"
  78. #include "iwl-testmode.h"
  79. #include "iwl-trans.h"
  80. #include "iwl-bus.h"
  81. #include "iwl-fh.h"
  82. /* The TLVs used in the gnl message policy between the kernel module and
  83. * user space application. iwl_testmode_gnl_msg_policy is to be carried
  84. * through the NL80211_CMD_TESTMODE channel regulated by nl80211.
  85. * See iwl-testmode.h
  86. */
  87. static
  88. struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = {
  89. [IWL_TM_ATTR_COMMAND] = { .type = NLA_U32, },
  90. [IWL_TM_ATTR_UCODE_CMD_ID] = { .type = NLA_U8, },
  91. [IWL_TM_ATTR_UCODE_CMD_DATA] = { .type = NLA_UNSPEC, },
  92. [IWL_TM_ATTR_REG_OFFSET] = { .type = NLA_U32, },
  93. [IWL_TM_ATTR_REG_VALUE8] = { .type = NLA_U8, },
  94. [IWL_TM_ATTR_REG_VALUE32] = { .type = NLA_U32, },
  95. [IWL_TM_ATTR_SYNC_RSP] = { .type = NLA_UNSPEC, },
  96. [IWL_TM_ATTR_UCODE_RX_PKT] = { .type = NLA_UNSPEC, },
  97. [IWL_TM_ATTR_EEPROM] = { .type = NLA_UNSPEC, },
  98. [IWL_TM_ATTR_TRACE_ADDR] = { .type = NLA_UNSPEC, },
  99. [IWL_TM_ATTR_TRACE_DUMP] = { .type = NLA_UNSPEC, },
  100. [IWL_TM_ATTR_TRACE_SIZE] = { .type = NLA_U32, },
  101. [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, },
  102. [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, },
  103. [IWL_TM_ATTR_SRAM_ADDR] = { .type = NLA_U32, },
  104. [IWL_TM_ATTR_SRAM_SIZE] = { .type = NLA_U32, },
  105. [IWL_TM_ATTR_SRAM_DUMP] = { .type = NLA_UNSPEC, },
  106. [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, },
  107. [IWL_TM_ATTR_DEVICE_ID] = { .type = NLA_U32, },
  108. [IWL_TM_ATTR_FW_TYPE] = { .type = NLA_U32, },
  109. [IWL_TM_ATTR_FW_INST_SIZE] = { .type = NLA_U32, },
  110. [IWL_TM_ATTR_FW_DATA_SIZE] = { .type = NLA_U32, },
  111. };
  112. /*
  113. * See the struct iwl_rx_packet in iwl-commands.h for the format of the
  114. * received events from the device
  115. */
  116. static inline int get_event_length(struct iwl_rx_mem_buffer *rxb)
  117. {
  118. struct iwl_rx_packet *pkt = rxb_addr(rxb);
  119. if (pkt)
  120. return le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK;
  121. else
  122. return 0;
  123. }
  124. /*
  125. * This function multicasts the spontaneous messages from the device to the
  126. * user space. It is invoked whenever there is a received messages
  127. * from the device. This function is called within the ISR of the rx handlers
  128. * in iwlagn driver.
  129. *
  130. * The parsing of the message content is left to the user space application,
  131. * The message content is treated as unattacked raw data and is encapsulated
  132. * with IWL_TM_ATTR_UCODE_RX_PKT multicasting to the user space.
  133. *
  134. * @priv: the instance of iwlwifi device
  135. * @rxb: pointer to rx data content received by the ISR
  136. *
  137. * See the message policies and TLVs in iwl_testmode_gnl_msg_policy[].
  138. * For the messages multicasting to the user application, the mandatory
  139. * TLV fields are :
  140. * IWL_TM_ATTR_COMMAND must be IWL_TM_CMD_DEV2APP_UCODE_RX_PKT
  141. * IWL_TM_ATTR_UCODE_RX_PKT for carrying the message content
  142. */
  143. static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv,
  144. struct iwl_rx_mem_buffer *rxb)
  145. {
  146. struct ieee80211_hw *hw = priv->hw;
  147. struct sk_buff *skb;
  148. void *data;
  149. int length;
  150. data = (void *)rxb_addr(rxb);
  151. length = get_event_length(rxb);
  152. if (!data || length == 0)
  153. return;
  154. skb = cfg80211_testmode_alloc_event_skb(hw->wiphy, 20 + length,
  155. GFP_ATOMIC);
  156. if (skb == NULL) {
  157. IWL_DEBUG_INFO(priv,
  158. "Run out of memory for messages to user space ?\n");
  159. return;
  160. }
  161. NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT);
  162. NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, length, data);
  163. cfg80211_testmode_event(skb, GFP_ATOMIC);
  164. return;
  165. nla_put_failure:
  166. kfree_skb(skb);
  167. IWL_DEBUG_INFO(priv, "Ouch, overran buffer, check allocation!\n");
  168. }
  169. void iwl_testmode_init(struct iwl_priv *priv)
  170. {
  171. priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt;
  172. priv->testmode_trace.trace_enabled = false;
  173. priv->testmode_sram.sram_readed = false;
  174. }
  175. static void iwl_sram_cleanup(struct iwl_priv *priv)
  176. {
  177. if (priv->testmode_sram.sram_readed) {
  178. kfree(priv->testmode_sram.buff_addr);
  179. priv->testmode_sram.buff_addr = NULL;
  180. priv->testmode_sram.buff_size = 0;
  181. priv->testmode_sram.num_chunks = 0;
  182. priv->testmode_sram.sram_readed = false;
  183. }
  184. }
  185. static void iwl_trace_cleanup(struct iwl_priv *priv)
  186. {
  187. if (priv->testmode_trace.trace_enabled) {
  188. if (priv->testmode_trace.cpu_addr &&
  189. priv->testmode_trace.dma_addr)
  190. dma_free_coherent(trans(priv)->dev,
  191. priv->testmode_trace.total_size,
  192. priv->testmode_trace.cpu_addr,
  193. priv->testmode_trace.dma_addr);
  194. priv->testmode_trace.trace_enabled = false;
  195. priv->testmode_trace.cpu_addr = NULL;
  196. priv->testmode_trace.trace_addr = NULL;
  197. priv->testmode_trace.dma_addr = 0;
  198. priv->testmode_trace.buff_size = 0;
  199. priv->testmode_trace.total_size = 0;
  200. }
  201. }
  202. void iwl_testmode_cleanup(struct iwl_priv *priv)
  203. {
  204. iwl_trace_cleanup(priv);
  205. iwl_sram_cleanup(priv);
  206. }
  207. /*
  208. * This function handles the user application commands to the ucode.
  209. *
  210. * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_CMD_ID and
  211. * IWL_TM_ATTR_UCODE_CMD_DATA and calls to the handler to send the
  212. * host command to the ucode.
  213. *
  214. * If any mandatory field is missing, -ENOMSG is replied to the user space
  215. * application; otherwise, the actual execution result of the host command to
  216. * ucode is replied.
  217. *
  218. * @hw: ieee80211_hw object that represents the device
  219. * @tb: gnl message fields from the user space
  220. */
  221. static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
  222. {
  223. struct iwl_priv *priv = hw->priv;
  224. struct iwl_host_cmd cmd;
  225. memset(&cmd, 0, sizeof(struct iwl_host_cmd));
  226. if (!tb[IWL_TM_ATTR_UCODE_CMD_ID] ||
  227. !tb[IWL_TM_ATTR_UCODE_CMD_DATA]) {
  228. IWL_DEBUG_INFO(priv,
  229. "Error finding ucode command mandatory fields\n");
  230. return -ENOMSG;
  231. }
  232. cmd.flags = CMD_ON_DEMAND;
  233. cmd.id = nla_get_u8(tb[IWL_TM_ATTR_UCODE_CMD_ID]);
  234. cmd.data[0] = nla_data(tb[IWL_TM_ATTR_UCODE_CMD_DATA]);
  235. cmd.len[0] = nla_len(tb[IWL_TM_ATTR_UCODE_CMD_DATA]);
  236. cmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY;
  237. IWL_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x,"
  238. " len %d\n", cmd.id, cmd.flags, cmd.len[0]);
  239. /* ok, let's submit the command to ucode */
  240. return iwl_trans_send_cmd(trans(priv), &cmd);
  241. }
  242. /*
  243. * This function handles the user application commands for register access.
  244. *
  245. * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the
  246. * handlers respectively.
  247. *
  248. * If it's an unknown commdn ID, -ENOSYS is returned; or -ENOMSG if the
  249. * mandatory fields(IWL_TM_ATTR_REG_OFFSET,IWL_TM_ATTR_REG_VALUE32,
  250. * IWL_TM_ATTR_REG_VALUE8) are missing; Otherwise 0 is replied indicating
  251. * the success of the command execution.
  252. *
  253. * If IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_REG_READ32, the register read
  254. * value is returned with IWL_TM_ATTR_REG_VALUE32.
  255. *
  256. * @hw: ieee80211_hw object that represents the device
  257. * @tb: gnl message fields from the user space
  258. */
  259. static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb)
  260. {
  261. struct iwl_priv *priv = hw->priv;
  262. u32 ofs, val32, cmd;
  263. u8 val8;
  264. struct sk_buff *skb;
  265. int status = 0;
  266. if (!tb[IWL_TM_ATTR_REG_OFFSET]) {
  267. IWL_DEBUG_INFO(priv, "Error finding register offset\n");
  268. return -ENOMSG;
  269. }
  270. ofs = nla_get_u32(tb[IWL_TM_ATTR_REG_OFFSET]);
  271. IWL_INFO(priv, "testmode register access command offset 0x%x\n", ofs);
  272. /* Allow access only to FH/CSR/HBUS in direct mode.
  273. Since we don't have the upper bounds for the CSR and HBUS segments,
  274. we will use only the upper bound of FH for sanity check. */
  275. cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]);
  276. if ((cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32 ||
  277. cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32 ||
  278. cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8) &&
  279. (ofs >= FH_MEM_UPPER_BOUND)) {
  280. IWL_DEBUG_INFO(priv, "offset out of segment (0x0 - 0x%x)\n",
  281. FH_MEM_UPPER_BOUND);
  282. return -EINVAL;
  283. }
  284. switch (cmd) {
  285. case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
  286. val32 = iwl_read_direct32(trans(priv), ofs);
  287. IWL_INFO(priv, "32bit value to read 0x%x\n", val32);
  288. skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
  289. if (!skb) {
  290. IWL_DEBUG_INFO(priv, "Error allocating memory\n");
  291. return -ENOMEM;
  292. }
  293. NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32);
  294. status = cfg80211_testmode_reply(skb);
  295. if (status < 0)
  296. IWL_DEBUG_INFO(priv,
  297. "Error sending msg : %d\n", status);
  298. break;
  299. case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32:
  300. if (!tb[IWL_TM_ATTR_REG_VALUE32]) {
  301. IWL_DEBUG_INFO(priv,
  302. "Error finding value to write\n");
  303. return -ENOMSG;
  304. } else {
  305. val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]);
  306. IWL_INFO(priv, "32bit value to write 0x%x\n", val32);
  307. iwl_write_direct32(trans(priv), ofs, val32);
  308. }
  309. break;
  310. case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
  311. if (!tb[IWL_TM_ATTR_REG_VALUE8]) {
  312. IWL_DEBUG_INFO(priv, "Error finding value to write\n");
  313. return -ENOMSG;
  314. } else {
  315. val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]);
  316. IWL_INFO(priv, "8bit value to write 0x%x\n", val8);
  317. iwl_write8(trans(priv), ofs, val8);
  318. }
  319. break;
  320. case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32:
  321. val32 = iwl_read_prph(trans(priv), ofs);
  322. IWL_INFO(priv, "32bit value to read 0x%x\n", val32);
  323. skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
  324. if (!skb) {
  325. IWL_DEBUG_INFO(priv, "Error allocating memory\n");
  326. return -ENOMEM;
  327. }
  328. NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32);
  329. status = cfg80211_testmode_reply(skb);
  330. if (status < 0)
  331. IWL_DEBUG_INFO(priv,
  332. "Error sending msg : %d\n", status);
  333. break;
  334. case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32:
  335. if (!tb[IWL_TM_ATTR_REG_VALUE32]) {
  336. IWL_DEBUG_INFO(priv,
  337. "Error finding value to write\n");
  338. return -ENOMSG;
  339. } else {
  340. val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]);
  341. IWL_INFO(priv, "32bit value to write 0x%x\n", val32);
  342. iwl_write_prph(trans(priv), ofs, val32);
  343. }
  344. break;
  345. default:
  346. IWL_DEBUG_INFO(priv, "Unknown testmode register command ID\n");
  347. return -ENOSYS;
  348. }
  349. return status;
  350. nla_put_failure:
  351. kfree_skb(skb);
  352. return -EMSGSIZE;
  353. }
  354. static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv)
  355. {
  356. struct iwl_notification_wait calib_wait;
  357. int ret;
  358. iwl_init_notification_wait(priv->shrd, &calib_wait,
  359. CALIBRATION_COMPLETE_NOTIFICATION,
  360. NULL, NULL);
  361. ret = iwl_init_alive_start(trans(priv));
  362. if (ret) {
  363. IWL_DEBUG_INFO(priv,
  364. "Error configuring init calibration: %d\n", ret);
  365. goto cfg_init_calib_error;
  366. }
  367. ret = iwl_wait_notification(priv->shrd, &calib_wait, 2 * HZ);
  368. if (ret)
  369. IWL_DEBUG_INFO(priv, "Error detecting"
  370. " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret);
  371. return ret;
  372. cfg_init_calib_error:
  373. iwl_remove_notification(priv->shrd, &calib_wait);
  374. return ret;
  375. }
  376. /*
  377. * This function handles the user application commands for driver.
  378. *
  379. * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the
  380. * handlers respectively.
  381. *
  382. * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned
  383. * value of the actual command execution is replied to the user application.
  384. *
  385. * If there's any message responding to the user space, IWL_TM_ATTR_SYNC_RSP
  386. * is used for carry the message while IWL_TM_ATTR_COMMAND must set to
  387. * IWL_TM_CMD_DEV2APP_SYNC_RSP.
  388. *
  389. * @hw: ieee80211_hw object that represents the device
  390. * @tb: gnl message fields from the user space
  391. */
  392. static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb)
  393. {
  394. struct iwl_priv *priv = hw->priv;
  395. struct iwl_trans *trans = trans(priv);
  396. struct sk_buff *skb;
  397. unsigned char *rsp_data_ptr = NULL;
  398. int status = 0, rsp_data_len = 0;
  399. u32 devid, inst_size = 0, data_size = 0;
  400. switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
  401. case IWL_TM_CMD_APP2DEV_GET_DEVICENAME:
  402. rsp_data_ptr = (unsigned char *)cfg(priv)->name;
  403. rsp_data_len = strlen(cfg(priv)->name);
  404. skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
  405. rsp_data_len + 20);
  406. if (!skb) {
  407. IWL_DEBUG_INFO(priv,
  408. "Error allocating memory\n");
  409. return -ENOMEM;
  410. }
  411. NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND,
  412. IWL_TM_CMD_DEV2APP_SYNC_RSP);
  413. NLA_PUT(skb, IWL_TM_ATTR_SYNC_RSP,
  414. rsp_data_len, rsp_data_ptr);
  415. status = cfg80211_testmode_reply(skb);
  416. if (status < 0)
  417. IWL_DEBUG_INFO(priv, "Error sending msg : %d\n",
  418. status);
  419. break;
  420. case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW:
  421. status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_INIT);
  422. if (status)
  423. IWL_DEBUG_INFO(priv,
  424. "Error loading init ucode: %d\n", status);
  425. break;
  426. case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB:
  427. iwl_testmode_cfg_init_calib(priv);
  428. iwl_trans_stop_device(trans);
  429. break;
  430. case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW:
  431. status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_REGULAR);
  432. if (status) {
  433. IWL_DEBUG_INFO(priv,
  434. "Error loading runtime ucode: %d\n", status);
  435. break;
  436. }
  437. status = iwl_alive_start(priv);
  438. if (status)
  439. IWL_DEBUG_INFO(priv,
  440. "Error starting the device: %d\n", status);
  441. break;
  442. case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW:
  443. iwl_scan_cancel_timeout(priv, 200);
  444. iwl_trans_stop_device(trans);
  445. status = iwl_load_ucode_wait_alive(trans, IWL_UCODE_WOWLAN);
  446. if (status) {
  447. IWL_DEBUG_INFO(priv,
  448. "Error loading WOWLAN ucode: %d\n", status);
  449. break;
  450. }
  451. status = iwl_alive_start(priv);
  452. if (status)
  453. IWL_DEBUG_INFO(priv,
  454. "Error starting the device: %d\n", status);
  455. break;
  456. case IWL_TM_CMD_APP2DEV_GET_EEPROM:
  457. if (priv->shrd->eeprom) {
  458. skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
  459. cfg(priv)->base_params->eeprom_size + 20);
  460. if (!skb) {
  461. IWL_DEBUG_INFO(priv,
  462. "Error allocating memory\n");
  463. return -ENOMEM;
  464. }
  465. NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND,
  466. IWL_TM_CMD_DEV2APP_EEPROM_RSP);
  467. NLA_PUT(skb, IWL_TM_ATTR_EEPROM,
  468. cfg(priv)->base_params->eeprom_size,
  469. priv->shrd->eeprom);
  470. status = cfg80211_testmode_reply(skb);
  471. if (status < 0)
  472. IWL_DEBUG_INFO(priv,
  473. "Error sending msg : %d\n",
  474. status);
  475. } else
  476. return -EFAULT;
  477. break;
  478. case IWL_TM_CMD_APP2DEV_FIXRATE_REQ:
  479. if (!tb[IWL_TM_ATTR_FIXRATE]) {
  480. IWL_DEBUG_INFO(priv,
  481. "Error finding fixrate setting\n");
  482. return -ENOMSG;
  483. }
  484. priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]);
  485. break;
  486. case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
  487. IWL_INFO(priv, "uCode version raw: 0x%x\n", priv->ucode_ver);
  488. skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
  489. if (!skb) {
  490. IWL_DEBUG_INFO(priv, "Error allocating memory\n");
  491. return -ENOMEM;
  492. }
  493. NLA_PUT_U32(skb, IWL_TM_ATTR_FW_VERSION, priv->ucode_ver);
  494. status = cfg80211_testmode_reply(skb);
  495. if (status < 0)
  496. IWL_DEBUG_INFO(priv,
  497. "Error sending msg : %d\n", status);
  498. break;
  499. case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
  500. devid = trans(priv)->hw_id;
  501. IWL_INFO(priv, "hw version: 0x%x\n", devid);
  502. skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20);
  503. if (!skb) {
  504. IWL_DEBUG_INFO(priv, "Error allocating memory\n");
  505. return -ENOMEM;
  506. }
  507. NLA_PUT_U32(skb, IWL_TM_ATTR_DEVICE_ID, devid);
  508. status = cfg80211_testmode_reply(skb);
  509. if (status < 0)
  510. IWL_DEBUG_INFO(priv,
  511. "Error sending msg : %d\n", status);
  512. break;
  513. case IWL_TM_CMD_APP2DEV_GET_FW_INFO:
  514. skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8);
  515. if (!skb) {
  516. IWL_DEBUG_INFO(priv, "Error allocating memory\n");
  517. return -ENOMEM;
  518. }
  519. switch (priv->shrd->ucode_type) {
  520. case IWL_UCODE_REGULAR:
  521. inst_size = trans(priv)->ucode_rt.code.len;
  522. data_size = trans(priv)->ucode_rt.data.len;
  523. break;
  524. case IWL_UCODE_INIT:
  525. inst_size = trans(priv)->ucode_init.code.len;
  526. data_size = trans(priv)->ucode_init.data.len;
  527. break;
  528. case IWL_UCODE_WOWLAN:
  529. inst_size = trans(priv)->ucode_wowlan.code.len;
  530. data_size = trans(priv)->ucode_wowlan.data.len;
  531. break;
  532. case IWL_UCODE_NONE:
  533. IWL_DEBUG_INFO(priv, "The uCode has not been loaded\n");
  534. break;
  535. default:
  536. IWL_DEBUG_INFO(priv, "Unsupported uCode type\n");
  537. break;
  538. }
  539. NLA_PUT_U32(skb, IWL_TM_ATTR_FW_TYPE, priv->shrd->ucode_type);
  540. NLA_PUT_U32(skb, IWL_TM_ATTR_FW_INST_SIZE, inst_size);
  541. NLA_PUT_U32(skb, IWL_TM_ATTR_FW_DATA_SIZE, data_size);
  542. status = cfg80211_testmode_reply(skb);
  543. if (status < 0)
  544. IWL_DEBUG_INFO(priv,
  545. "Error sending msg : %d\n", status);
  546. break;
  547. default:
  548. IWL_DEBUG_INFO(priv, "Unknown testmode driver command ID\n");
  549. return -ENOSYS;
  550. }
  551. return status;
  552. nla_put_failure:
  553. kfree_skb(skb);
  554. return -EMSGSIZE;
  555. }
  556. /*
  557. * This function handles the user application commands for uCode trace
  558. *
  559. * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the
  560. * handlers respectively.
  561. *
  562. * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned
  563. * value of the actual command execution is replied to the user application.
  564. *
  565. * @hw: ieee80211_hw object that represents the device
  566. * @tb: gnl message fields from the user space
  567. */
  568. static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb)
  569. {
  570. struct iwl_priv *priv = hw->priv;
  571. struct sk_buff *skb;
  572. int status = 0;
  573. struct device *dev = trans(priv)->dev;
  574. switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
  575. case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
  576. if (priv->testmode_trace.trace_enabled)
  577. return -EBUSY;
  578. if (!tb[IWL_TM_ATTR_TRACE_SIZE])
  579. priv->testmode_trace.buff_size = TRACE_BUFF_SIZE_DEF;
  580. else
  581. priv->testmode_trace.buff_size =
  582. nla_get_u32(tb[IWL_TM_ATTR_TRACE_SIZE]);
  583. if (!priv->testmode_trace.buff_size)
  584. return -EINVAL;
  585. if (priv->testmode_trace.buff_size < TRACE_BUFF_SIZE_MIN ||
  586. priv->testmode_trace.buff_size > TRACE_BUFF_SIZE_MAX)
  587. return -EINVAL;
  588. priv->testmode_trace.total_size =
  589. priv->testmode_trace.buff_size + TRACE_BUFF_PADD;
  590. priv->testmode_trace.cpu_addr =
  591. dma_alloc_coherent(dev,
  592. priv->testmode_trace.total_size,
  593. &priv->testmode_trace.dma_addr,
  594. GFP_KERNEL);
  595. if (!priv->testmode_trace.cpu_addr)
  596. return -ENOMEM;
  597. priv->testmode_trace.trace_enabled = true;
  598. priv->testmode_trace.trace_addr = (u8 *)PTR_ALIGN(
  599. priv->testmode_trace.cpu_addr, 0x100);
  600. memset(priv->testmode_trace.trace_addr, 0x03B,
  601. priv->testmode_trace.buff_size);
  602. skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy,
  603. sizeof(priv->testmode_trace.dma_addr) + 20);
  604. if (!skb) {
  605. IWL_DEBUG_INFO(priv,
  606. "Error allocating memory\n");
  607. iwl_trace_cleanup(priv);
  608. return -ENOMEM;
  609. }
  610. NLA_PUT(skb, IWL_TM_ATTR_TRACE_ADDR,
  611. sizeof(priv->testmode_trace.dma_addr),
  612. (u64 *)&priv->testmode_trace.dma_addr);
  613. status = cfg80211_testmode_reply(skb);
  614. if (status < 0) {
  615. IWL_DEBUG_INFO(priv,
  616. "Error sending msg : %d\n",
  617. status);
  618. }
  619. priv->testmode_trace.num_chunks =
  620. DIV_ROUND_UP(priv->testmode_trace.buff_size,
  621. DUMP_CHUNK_SIZE);
  622. break;
  623. case IWL_TM_CMD_APP2DEV_END_TRACE:
  624. iwl_trace_cleanup(priv);
  625. break;
  626. default:
  627. IWL_DEBUG_INFO(priv, "Unknown testmode mem command ID\n");
  628. return -ENOSYS;
  629. }
  630. return status;
  631. nla_put_failure:
  632. kfree_skb(skb);
  633. if (nla_get_u32(tb[IWL_TM_ATTR_COMMAND]) ==
  634. IWL_TM_CMD_APP2DEV_BEGIN_TRACE)
  635. iwl_trace_cleanup(priv);
  636. return -EMSGSIZE;
  637. }
  638. static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb,
  639. struct sk_buff *skb,
  640. struct netlink_callback *cb)
  641. {
  642. struct iwl_priv *priv = hw->priv;
  643. int idx, length;
  644. if (priv->testmode_trace.trace_enabled &&
  645. priv->testmode_trace.trace_addr) {
  646. idx = cb->args[4];
  647. if (idx >= priv->testmode_trace.num_chunks)
  648. return -ENOENT;
  649. length = DUMP_CHUNK_SIZE;
  650. if (((idx + 1) == priv->testmode_trace.num_chunks) &&
  651. (priv->testmode_trace.buff_size % DUMP_CHUNK_SIZE))
  652. length = priv->testmode_trace.buff_size %
  653. DUMP_CHUNK_SIZE;
  654. NLA_PUT(skb, IWL_TM_ATTR_TRACE_DUMP, length,
  655. priv->testmode_trace.trace_addr +
  656. (DUMP_CHUNK_SIZE * idx));
  657. idx++;
  658. cb->args[4] = idx;
  659. return 0;
  660. } else
  661. return -EFAULT;
  662. nla_put_failure:
  663. return -ENOBUFS;
  664. }
  665. /*
  666. * This function handles the user application switch ucode ownership.
  667. *
  668. * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_OWNER and
  669. * decide who the current owner of the uCode
  670. *
  671. * If the current owner is OWNERSHIP_TM, then the only host command
  672. * can deliver to uCode is from testmode, all the other host commands
  673. * will dropped.
  674. *
  675. * default driver is the owner of uCode in normal operational mode
  676. *
  677. * @hw: ieee80211_hw object that represents the device
  678. * @tb: gnl message fields from the user space
  679. */
  680. static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb)
  681. {
  682. struct iwl_priv *priv = hw->priv;
  683. u8 owner;
  684. if (!tb[IWL_TM_ATTR_UCODE_OWNER]) {
  685. IWL_DEBUG_INFO(priv, "Error finding ucode owner\n");
  686. return -ENOMSG;
  687. }
  688. owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]);
  689. if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM))
  690. priv->shrd->ucode_owner = owner;
  691. else {
  692. IWL_DEBUG_INFO(priv, "Invalid owner\n");
  693. return -EINVAL;
  694. }
  695. return 0;
  696. }
  697. /*
  698. * This function handles the user application commands for SRAM data dump
  699. *
  700. * It retrieves the mandatory fields IWL_TM_ATTR_SRAM_ADDR and
  701. * IWL_TM_ATTR_SRAM_SIZE to decide the memory area for SRAM data reading
  702. *
  703. * Several error will be retured, -EBUSY if the SRAM data retrieved by
  704. * previous command has not been delivered to userspace, or -ENOMSG if
  705. * the mandatory fields (IWL_TM_ATTR_SRAM_ADDR,IWL_TM_ATTR_SRAM_SIZE)
  706. * are missing, or -ENOMEM if the buffer allocation fails.
  707. *
  708. * Otherwise 0 is replied indicating the success of the SRAM reading.
  709. *
  710. * @hw: ieee80211_hw object that represents the device
  711. * @tb: gnl message fields from the user space
  712. */
  713. static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb)
  714. {
  715. struct iwl_priv *priv = hw->priv;
  716. u32 ofs, size, maxsize;
  717. if (priv->testmode_sram.sram_readed)
  718. return -EBUSY;
  719. if (!tb[IWL_TM_ATTR_SRAM_ADDR]) {
  720. IWL_DEBUG_INFO(priv, "Error finding SRAM offset address\n");
  721. return -ENOMSG;
  722. }
  723. ofs = nla_get_u32(tb[IWL_TM_ATTR_SRAM_ADDR]);
  724. if (!tb[IWL_TM_ATTR_SRAM_SIZE]) {
  725. IWL_DEBUG_INFO(priv, "Error finding size for SRAM reading\n");
  726. return -ENOMSG;
  727. }
  728. size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]);
  729. switch (priv->shrd->ucode_type) {
  730. case IWL_UCODE_REGULAR:
  731. maxsize = trans(priv)->ucode_rt.data.len;
  732. break;
  733. case IWL_UCODE_INIT:
  734. maxsize = trans(priv)->ucode_init.data.len;
  735. break;
  736. case IWL_UCODE_WOWLAN:
  737. maxsize = trans(priv)->ucode_wowlan.data.len;
  738. break;
  739. case IWL_UCODE_NONE:
  740. IWL_ERR(priv, "Error, uCode does not been loaded\n");
  741. return -ENOSYS;
  742. default:
  743. IWL_ERR(priv, "Error, unsupported uCode type\n");
  744. return -ENOSYS;
  745. }
  746. if ((ofs + size) > (maxsize + SRAM_DATA_SEG_OFFSET)) {
  747. IWL_ERR(priv, "Invalid offset/size: out of range\n");
  748. return -EINVAL;
  749. }
  750. priv->testmode_sram.buff_size = (size / 4) * 4;
  751. priv->testmode_sram.buff_addr =
  752. kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL);
  753. if (priv->testmode_sram.buff_addr == NULL) {
  754. IWL_ERR(priv, "Error allocating memory\n");
  755. return -ENOMEM;
  756. }
  757. _iwl_read_targ_mem_words(trans(priv), ofs,
  758. priv->testmode_sram.buff_addr,
  759. priv->testmode_sram.buff_size / 4);
  760. priv->testmode_sram.num_chunks =
  761. DIV_ROUND_UP(priv->testmode_sram.buff_size, DUMP_CHUNK_SIZE);
  762. priv->testmode_sram.sram_readed = true;
  763. return 0;
  764. }
  765. static int iwl_testmode_sram_dump(struct ieee80211_hw *hw, struct nlattr **tb,
  766. struct sk_buff *skb,
  767. struct netlink_callback *cb)
  768. {
  769. struct iwl_priv *priv = hw->priv;
  770. int idx, length;
  771. if (priv->testmode_sram.sram_readed) {
  772. idx = cb->args[4];
  773. if (idx >= priv->testmode_sram.num_chunks) {
  774. iwl_sram_cleanup(priv);
  775. return -ENOENT;
  776. }
  777. length = DUMP_CHUNK_SIZE;
  778. if (((idx + 1) == priv->testmode_sram.num_chunks) &&
  779. (priv->testmode_sram.buff_size % DUMP_CHUNK_SIZE))
  780. length = priv->testmode_sram.buff_size %
  781. DUMP_CHUNK_SIZE;
  782. NLA_PUT(skb, IWL_TM_ATTR_SRAM_DUMP, length,
  783. priv->testmode_sram.buff_addr +
  784. (DUMP_CHUNK_SIZE * idx));
  785. idx++;
  786. cb->args[4] = idx;
  787. return 0;
  788. } else
  789. return -EFAULT;
  790. nla_put_failure:
  791. return -ENOBUFS;
  792. }
  793. /* The testmode gnl message handler that takes the gnl message from the
  794. * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then
  795. * invoke the corresponding handlers.
  796. *
  797. * This function is invoked when there is user space application sending
  798. * gnl message through the testmode tunnel NL80211_CMD_TESTMODE regulated
  799. * by nl80211.
  800. *
  801. * It retrieves the mandatory field, IWL_TM_ATTR_COMMAND, before
  802. * dispatching it to the corresponding handler.
  803. *
  804. * If IWL_TM_ATTR_COMMAND is missing, -ENOMSG is replied to user application;
  805. * -ENOSYS is replied to the user application if the command is unknown;
  806. * Otherwise, the command is dispatched to the respective handler.
  807. *
  808. * @hw: ieee80211_hw object that represents the device
  809. * @data: pointer to user space message
  810. * @len: length in byte of @data
  811. */
  812. int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len)
  813. {
  814. struct nlattr *tb[IWL_TM_ATTR_MAX];
  815. struct iwl_priv *priv = hw->priv;
  816. int result;
  817. result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len,
  818. iwl_testmode_gnl_msg_policy);
  819. if (result != 0) {
  820. IWL_DEBUG_INFO(priv,
  821. "Error parsing the gnl message : %d\n", result);
  822. return result;
  823. }
  824. /* IWL_TM_ATTR_COMMAND is absolutely mandatory */
  825. if (!tb[IWL_TM_ATTR_COMMAND]) {
  826. IWL_DEBUG_INFO(priv, "Error finding testmode command type\n");
  827. return -ENOMSG;
  828. }
  829. /* in case multiple accesses to the device happens */
  830. mutex_lock(&priv->shrd->mutex);
  831. switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
  832. case IWL_TM_CMD_APP2DEV_UCODE:
  833. IWL_DEBUG_INFO(priv, "testmode cmd to uCode\n");
  834. result = iwl_testmode_ucode(hw, tb);
  835. break;
  836. case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32:
  837. case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32:
  838. case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8:
  839. case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32:
  840. case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32:
  841. IWL_DEBUG_INFO(priv, "testmode cmd to register\n");
  842. result = iwl_testmode_reg(hw, tb);
  843. break;
  844. case IWL_TM_CMD_APP2DEV_GET_DEVICENAME:
  845. case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW:
  846. case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB:
  847. case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW:
  848. case IWL_TM_CMD_APP2DEV_GET_EEPROM:
  849. case IWL_TM_CMD_APP2DEV_FIXRATE_REQ:
  850. case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW:
  851. case IWL_TM_CMD_APP2DEV_GET_FW_VERSION:
  852. case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID:
  853. case IWL_TM_CMD_APP2DEV_GET_FW_INFO:
  854. IWL_DEBUG_INFO(priv, "testmode cmd to driver\n");
  855. result = iwl_testmode_driver(hw, tb);
  856. break;
  857. case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
  858. case IWL_TM_CMD_APP2DEV_END_TRACE:
  859. case IWL_TM_CMD_APP2DEV_READ_TRACE:
  860. IWL_DEBUG_INFO(priv, "testmode uCode trace cmd to driver\n");
  861. result = iwl_testmode_trace(hw, tb);
  862. break;
  863. case IWL_TM_CMD_APP2DEV_OWNERSHIP:
  864. IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n");
  865. result = iwl_testmode_ownership(hw, tb);
  866. break;
  867. case IWL_TM_CMD_APP2DEV_READ_SRAM:
  868. IWL_DEBUG_INFO(priv, "testmode sram read cmd to driver\n");
  869. result = iwl_testmode_sram(hw, tb);
  870. break;
  871. default:
  872. IWL_DEBUG_INFO(priv, "Unknown testmode command\n");
  873. result = -ENOSYS;
  874. break;
  875. }
  876. mutex_unlock(&priv->shrd->mutex);
  877. return result;
  878. }
  879. int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb,
  880. struct netlink_callback *cb,
  881. void *data, int len)
  882. {
  883. struct nlattr *tb[IWL_TM_ATTR_MAX];
  884. struct iwl_priv *priv = hw->priv;
  885. int result;
  886. u32 cmd;
  887. if (cb->args[3]) {
  888. /* offset by 1 since commands start at 0 */
  889. cmd = cb->args[3] - 1;
  890. } else {
  891. result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len,
  892. iwl_testmode_gnl_msg_policy);
  893. if (result) {
  894. IWL_DEBUG_INFO(priv,
  895. "Error parsing the gnl message : %d\n", result);
  896. return result;
  897. }
  898. /* IWL_TM_ATTR_COMMAND is absolutely mandatory */
  899. if (!tb[IWL_TM_ATTR_COMMAND]) {
  900. IWL_DEBUG_INFO(priv,
  901. "Error finding testmode command type\n");
  902. return -ENOMSG;
  903. }
  904. cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]);
  905. cb->args[3] = cmd + 1;
  906. }
  907. /* in case multiple accesses to the device happens */
  908. mutex_lock(&priv->shrd->mutex);
  909. switch (cmd) {
  910. case IWL_TM_CMD_APP2DEV_READ_TRACE:
  911. IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n");
  912. result = iwl_testmode_trace_dump(hw, tb, skb, cb);
  913. break;
  914. case IWL_TM_CMD_APP2DEV_DUMP_SRAM:
  915. IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n");
  916. result = iwl_testmode_sram_dump(hw, tb, skb, cb);
  917. break;
  918. default:
  919. result = -EINVAL;
  920. break;
  921. }
  922. mutex_unlock(&priv->shrd->mutex);
  923. return result;
  924. }