commands.c 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  1. /*
  2. * Intel Wireless Multicomm 3200 WiFi driver
  3. *
  4. * Copyright (C) 2009 Intel Corporation. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in
  14. * the documentation and/or other materials provided with the
  15. * distribution.
  16. * * Neither the name of Intel Corporation nor the names of its
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. *
  33. * Intel Corporation <ilw@linux.intel.com>
  34. * Samuel Ortiz <samuel.ortiz@intel.com>
  35. * Zhu Yi <yi.zhu@intel.com>
  36. *
  37. */
  38. #include <linux/kernel.h>
  39. #include <linux/wireless.h>
  40. #include <linux/etherdevice.h>
  41. #include <linux/ieee80211.h>
  42. #include <linux/sched.h>
  43. #include <linux/slab.h>
  44. #include "iwm.h"
  45. #include "bus.h"
  46. #include "hal.h"
  47. #include "umac.h"
  48. #include "commands.h"
  49. #include "debug.h"
  50. static int iwm_send_lmac_ptrough_cmd(struct iwm_priv *iwm,
  51. u8 lmac_cmd_id,
  52. const void *lmac_payload,
  53. u16 lmac_payload_size,
  54. u8 resp)
  55. {
  56. struct iwm_udma_wifi_cmd udma_cmd = UDMA_LMAC_INIT;
  57. struct iwm_umac_cmd umac_cmd;
  58. struct iwm_lmac_cmd lmac_cmd;
  59. lmac_cmd.id = lmac_cmd_id;
  60. umac_cmd.id = UMAC_CMD_OPCODE_WIFI_PASS_THROUGH;
  61. umac_cmd.resp = resp;
  62. return iwm_hal_send_host_cmd(iwm, &udma_cmd, &umac_cmd, &lmac_cmd,
  63. lmac_payload, lmac_payload_size);
  64. }
  65. int iwm_send_wifi_if_cmd(struct iwm_priv *iwm, void *payload, u16 payload_size,
  66. bool resp)
  67. {
  68. struct iwm_umac_wifi_if *hdr = (struct iwm_umac_wifi_if *)payload;
  69. struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
  70. struct iwm_umac_cmd umac_cmd;
  71. int ret;
  72. u8 oid = hdr->oid;
  73. if (!test_bit(IWM_STATUS_READY, &iwm->status)) {
  74. IWM_ERR(iwm, "Interface is not ready yet");
  75. return -EAGAIN;
  76. }
  77. umac_cmd.id = UMAC_CMD_OPCODE_WIFI_IF_WRAPPER;
  78. umac_cmd.resp = resp;
  79. ret = iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd,
  80. payload, payload_size);
  81. if (resp) {
  82. ret = wait_event_interruptible_timeout(iwm->wifi_ntfy_queue,
  83. test_and_clear_bit(oid, &iwm->wifi_ntfy[0]),
  84. 3 * HZ);
  85. return ret ? 0 : -EBUSY;
  86. }
  87. return ret;
  88. }
  89. static int modparam_wiwi = COEX_MODE_CM;
  90. module_param_named(wiwi, modparam_wiwi, int, 0644);
  91. MODULE_PARM_DESC(wiwi, "Wifi-WiMAX coexistence: 1=SA, 2=XOR, 3=CM (default)");
  92. static struct coex_event iwm_sta_xor_prio_tbl[COEX_EVENTS_NUM] =
  93. {
  94. {4, 3, 0, COEX_UNASSOC_IDLE_FLAGS},
  95. {4, 3, 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS},
  96. {4, 3, 0, COEX_UNASSOC_AUTO_SCAN_FLAGS},
  97. {4, 3, 0, COEX_CALIBRATION_FLAGS},
  98. {4, 3, 0, COEX_PERIODIC_CALIBRATION_FLAGS},
  99. {4, 3, 0, COEX_CONNECTION_ESTAB_FLAGS},
  100. {4, 3, 0, COEX_ASSOCIATED_IDLE_FLAGS},
  101. {4, 3, 0, COEX_ASSOC_MANUAL_SCAN_FLAGS},
  102. {4, 3, 0, COEX_ASSOC_AUTO_SCAN_FLAGS},
  103. {4, 3, 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS},
  104. {6, 3, 0, COEX_XOR_RF_ON_FLAGS},
  105. {4, 3, 0, COEX_RF_OFF_FLAGS},
  106. {6, 6, 0, COEX_STAND_ALONE_DEBUG_FLAGS},
  107. {4, 3, 0, COEX_IPAN_ASSOC_LEVEL_FLAGS},
  108. {4, 3, 0, COEX_RSRVD1_FLAGS},
  109. {4, 3, 0, COEX_RSRVD2_FLAGS}
  110. };
  111. static struct coex_event iwm_sta_cm_prio_tbl[COEX_EVENTS_NUM] =
  112. {
  113. {1, 1, 0, COEX_UNASSOC_IDLE_FLAGS},
  114. {4, 4, 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS},
  115. {3, 3, 0, COEX_UNASSOC_AUTO_SCAN_FLAGS},
  116. {6, 6, 0, COEX_CALIBRATION_FLAGS},
  117. {3, 3, 0, COEX_PERIODIC_CALIBRATION_FLAGS},
  118. {6, 5, 0, COEX_CONNECTION_ESTAB_FLAGS},
  119. {4, 4, 0, COEX_ASSOCIATED_IDLE_FLAGS},
  120. {4, 4, 0, COEX_ASSOC_MANUAL_SCAN_FLAGS},
  121. {4, 4, 0, COEX_ASSOC_AUTO_SCAN_FLAGS},
  122. {4, 4, 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS},
  123. {1, 1, 0, COEX_RF_ON_FLAGS},
  124. {1, 1, 0, COEX_RF_OFF_FLAGS},
  125. {7, 7, 0, COEX_STAND_ALONE_DEBUG_FLAGS},
  126. {5, 4, 0, COEX_IPAN_ASSOC_LEVEL_FLAGS},
  127. {1, 1, 0, COEX_RSRVD1_FLAGS},
  128. {1, 1, 0, COEX_RSRVD2_FLAGS}
  129. };
  130. int iwm_send_prio_table(struct iwm_priv *iwm)
  131. {
  132. struct iwm_coex_prio_table_cmd coex_table_cmd;
  133. u32 coex_enabled, mode_enabled;
  134. memset(&coex_table_cmd, 0, sizeof(struct iwm_coex_prio_table_cmd));
  135. coex_table_cmd.flags = COEX_FLAGS_STA_TABLE_VALID_MSK;
  136. switch (modparam_wiwi) {
  137. case COEX_MODE_XOR:
  138. case COEX_MODE_CM:
  139. coex_enabled = 1;
  140. break;
  141. default:
  142. coex_enabled = 0;
  143. break;
  144. }
  145. switch (iwm->conf.mode) {
  146. case UMAC_MODE_BSS:
  147. case UMAC_MODE_IBSS:
  148. mode_enabled = 1;
  149. break;
  150. default:
  151. mode_enabled = 0;
  152. break;
  153. }
  154. if (coex_enabled && mode_enabled) {
  155. coex_table_cmd.flags |= COEX_FLAGS_COEX_ENABLE_MSK |
  156. COEX_FLAGS_ASSOC_WAKEUP_UMASK_MSK |
  157. COEX_FLAGS_UNASSOC_WAKEUP_UMASK_MSK;
  158. switch (modparam_wiwi) {
  159. case COEX_MODE_XOR:
  160. memcpy(coex_table_cmd.sta_prio, iwm_sta_xor_prio_tbl,
  161. sizeof(iwm_sta_xor_prio_tbl));
  162. break;
  163. case COEX_MODE_CM:
  164. memcpy(coex_table_cmd.sta_prio, iwm_sta_cm_prio_tbl,
  165. sizeof(iwm_sta_cm_prio_tbl));
  166. break;
  167. default:
  168. IWM_ERR(iwm, "Invalid coex_mode 0x%x\n",
  169. modparam_wiwi);
  170. break;
  171. }
  172. } else
  173. IWM_WARN(iwm, "coexistense disabled\n");
  174. return iwm_send_lmac_ptrough_cmd(iwm, COEX_PRIORITY_TABLE_CMD,
  175. &coex_table_cmd,
  176. sizeof(struct iwm_coex_prio_table_cmd), 0);
  177. }
  178. int iwm_send_init_calib_cfg(struct iwm_priv *iwm, u8 calib_requested)
  179. {
  180. struct iwm_lmac_cal_cfg_cmd cal_cfg_cmd;
  181. memset(&cal_cfg_cmd, 0, sizeof(struct iwm_lmac_cal_cfg_cmd));
  182. cal_cfg_cmd.ucode_cfg.init.enable = cpu_to_le32(calib_requested);
  183. cal_cfg_cmd.ucode_cfg.init.start = cpu_to_le32(calib_requested);
  184. cal_cfg_cmd.ucode_cfg.init.send_res = cpu_to_le32(calib_requested);
  185. cal_cfg_cmd.ucode_cfg.flags =
  186. cpu_to_le32(CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_AFTER_MSK);
  187. return iwm_send_lmac_ptrough_cmd(iwm, CALIBRATION_CFG_CMD, &cal_cfg_cmd,
  188. sizeof(struct iwm_lmac_cal_cfg_cmd), 1);
  189. }
  190. int iwm_send_periodic_calib_cfg(struct iwm_priv *iwm, u8 calib_requested)
  191. {
  192. struct iwm_lmac_cal_cfg_cmd cal_cfg_cmd;
  193. memset(&cal_cfg_cmd, 0, sizeof(struct iwm_lmac_cal_cfg_cmd));
  194. cal_cfg_cmd.ucode_cfg.periodic.enable = cpu_to_le32(calib_requested);
  195. cal_cfg_cmd.ucode_cfg.periodic.start = cpu_to_le32(calib_requested);
  196. return iwm_send_lmac_ptrough_cmd(iwm, CALIBRATION_CFG_CMD, &cal_cfg_cmd,
  197. sizeof(struct iwm_lmac_cal_cfg_cmd), 0);
  198. }
  199. int iwm_store_rxiq_calib_result(struct iwm_priv *iwm)
  200. {
  201. struct iwm_calib_rxiq *rxiq;
  202. u8 *eeprom_rxiq = iwm_eeprom_access(iwm, IWM_EEPROM_CALIB_RXIQ);
  203. int grplen = sizeof(struct iwm_calib_rxiq_group);
  204. rxiq = kzalloc(sizeof(struct iwm_calib_rxiq), GFP_KERNEL);
  205. if (!rxiq) {
  206. IWM_ERR(iwm, "Couldn't alloc memory for RX IQ\n");
  207. return -ENOMEM;
  208. }
  209. eeprom_rxiq = iwm_eeprom_access(iwm, IWM_EEPROM_CALIB_RXIQ);
  210. if (IS_ERR(eeprom_rxiq)) {
  211. IWM_ERR(iwm, "Couldn't access EEPROM RX IQ entry\n");
  212. kfree(rxiq);
  213. return PTR_ERR(eeprom_rxiq);
  214. }
  215. iwm->calib_res[SHILOH_PHY_CALIBRATE_RX_IQ_CMD].buf = (u8 *)rxiq;
  216. iwm->calib_res[SHILOH_PHY_CALIBRATE_RX_IQ_CMD].size = sizeof(*rxiq);
  217. rxiq->hdr.opcode = SHILOH_PHY_CALIBRATE_RX_IQ_CMD;
  218. rxiq->hdr.first_grp = 0;
  219. rxiq->hdr.grp_num = 1;
  220. rxiq->hdr.all_data_valid = 1;
  221. memcpy(&rxiq->group[0], eeprom_rxiq, 4 * grplen);
  222. memcpy(&rxiq->group[4], eeprom_rxiq + 6 * grplen, grplen);
  223. return 0;
  224. }
  225. int iwm_send_calib_results(struct iwm_priv *iwm)
  226. {
  227. int i, ret = 0;
  228. for (i = PHY_CALIBRATE_OPCODES_NUM; i < CALIBRATION_CMD_NUM; i++) {
  229. if (test_bit(i - PHY_CALIBRATE_OPCODES_NUM,
  230. &iwm->calib_done_map)) {
  231. IWM_DBG_CMD(iwm, DBG,
  232. "Send calibration %d result\n", i);
  233. ret |= iwm_send_lmac_ptrough_cmd(iwm,
  234. REPLY_PHY_CALIBRATION_CMD,
  235. iwm->calib_res[i].buf,
  236. iwm->calib_res[i].size, 0);
  237. kfree(iwm->calib_res[i].buf);
  238. iwm->calib_res[i].buf = NULL;
  239. iwm->calib_res[i].size = 0;
  240. }
  241. }
  242. return ret;
  243. }
  244. int iwm_send_ct_kill_cfg(struct iwm_priv *iwm, u8 entry, u8 exit)
  245. {
  246. struct iwm_ct_kill_cfg_cmd cmd;
  247. cmd.entry_threshold = entry;
  248. cmd.exit_threshold = exit;
  249. return iwm_send_lmac_ptrough_cmd(iwm, REPLY_CT_KILL_CONFIG_CMD, &cmd,
  250. sizeof(struct iwm_ct_kill_cfg_cmd), 0);
  251. }
  252. int iwm_send_umac_reset(struct iwm_priv *iwm, __le32 reset_flags, bool resp)
  253. {
  254. struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
  255. struct iwm_umac_cmd umac_cmd;
  256. struct iwm_umac_cmd_reset reset;
  257. reset.flags = reset_flags;
  258. umac_cmd.id = UMAC_CMD_OPCODE_RESET;
  259. umac_cmd.resp = resp;
  260. return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, &reset,
  261. sizeof(struct iwm_umac_cmd_reset));
  262. }
  263. int iwm_umac_set_config_fix(struct iwm_priv *iwm, u16 tbl, u16 key, u32 value)
  264. {
  265. struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
  266. struct iwm_umac_cmd umac_cmd;
  267. struct iwm_umac_cmd_set_param_fix param;
  268. if ((tbl != UMAC_PARAM_TBL_CFG_FIX) &&
  269. (tbl != UMAC_PARAM_TBL_FA_CFG_FIX))
  270. return -EINVAL;
  271. umac_cmd.id = UMAC_CMD_OPCODE_SET_PARAM_FIX;
  272. umac_cmd.resp = 0;
  273. param.tbl = cpu_to_le16(tbl);
  274. param.key = cpu_to_le16(key);
  275. param.value = cpu_to_le32(value);
  276. return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, &param,
  277. sizeof(struct iwm_umac_cmd_set_param_fix));
  278. }
  279. int iwm_umac_set_config_var(struct iwm_priv *iwm, u16 key,
  280. void *payload, u16 payload_size)
  281. {
  282. struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
  283. struct iwm_umac_cmd umac_cmd;
  284. struct iwm_umac_cmd_set_param_var *param_hdr;
  285. u8 *param;
  286. int ret;
  287. param = kzalloc(payload_size +
  288. sizeof(struct iwm_umac_cmd_set_param_var), GFP_KERNEL);
  289. if (!param) {
  290. IWM_ERR(iwm, "Couldn't allocate param\n");
  291. return -ENOMEM;
  292. }
  293. param_hdr = (struct iwm_umac_cmd_set_param_var *)param;
  294. umac_cmd.id = UMAC_CMD_OPCODE_SET_PARAM_VAR;
  295. umac_cmd.resp = 0;
  296. param_hdr->tbl = cpu_to_le16(UMAC_PARAM_TBL_CFG_VAR);
  297. param_hdr->key = cpu_to_le16(key);
  298. param_hdr->len = cpu_to_le16(payload_size);
  299. memcpy(param + sizeof(struct iwm_umac_cmd_set_param_var),
  300. payload, payload_size);
  301. ret = iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, param,
  302. sizeof(struct iwm_umac_cmd_set_param_var) +
  303. payload_size);
  304. kfree(param);
  305. return ret;
  306. }
  307. int iwm_send_umac_config(struct iwm_priv *iwm, __le32 reset_flags)
  308. {
  309. int ret;
  310. /* Use UMAC default values */
  311. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  312. CFG_POWER_INDEX, iwm->conf.power_index);
  313. if (ret < 0)
  314. return ret;
  315. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_FA_CFG_FIX,
  316. CFG_FRAG_THRESHOLD,
  317. iwm->conf.frag_threshold);
  318. if (ret < 0)
  319. return ret;
  320. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  321. CFG_RTS_THRESHOLD,
  322. iwm->conf.rts_threshold);
  323. if (ret < 0)
  324. return ret;
  325. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  326. CFG_CTS_TO_SELF, iwm->conf.cts_to_self);
  327. if (ret < 0)
  328. return ret;
  329. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  330. CFG_WIRELESS_MODE,
  331. iwm->conf.wireless_mode);
  332. if (ret < 0)
  333. return ret;
  334. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  335. CFG_COEX_MODE, modparam_wiwi);
  336. if (ret < 0)
  337. return ret;
  338. /*
  339. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  340. CFG_ASSOCIATION_TIMEOUT,
  341. iwm->conf.assoc_timeout);
  342. if (ret < 0)
  343. return ret;
  344. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  345. CFG_ROAM_TIMEOUT,
  346. iwm->conf.roam_timeout);
  347. if (ret < 0)
  348. return ret;
  349. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  350. CFG_WIRELESS_MODE,
  351. WIRELESS_MODE_11A | WIRELESS_MODE_11G);
  352. if (ret < 0)
  353. return ret;
  354. */
  355. ret = iwm_umac_set_config_var(iwm, CFG_NET_ADDR,
  356. iwm_to_ndev(iwm)->dev_addr, ETH_ALEN);
  357. if (ret < 0)
  358. return ret;
  359. /* UMAC PM static configurations */
  360. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  361. CFG_PM_LEGACY_RX_TIMEOUT, 0x12C);
  362. if (ret < 0)
  363. return ret;
  364. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  365. CFG_PM_LEGACY_TX_TIMEOUT, 0x15E);
  366. if (ret < 0)
  367. return ret;
  368. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  369. CFG_PM_CTRL_FLAGS, 0x1);
  370. if (ret < 0)
  371. return ret;
  372. ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX,
  373. CFG_PM_KEEP_ALIVE_IN_BEACONS, 0x80);
  374. if (ret < 0)
  375. return ret;
  376. /* reset UMAC */
  377. ret = iwm_send_umac_reset(iwm, reset_flags, 1);
  378. if (ret < 0)
  379. return ret;
  380. ret = iwm_notif_handle(iwm, UMAC_CMD_OPCODE_RESET, IWM_SRC_UMAC,
  381. WAIT_NOTIF_TIMEOUT);
  382. if (ret) {
  383. IWM_ERR(iwm, "Wait for UMAC RESET timeout\n");
  384. return ret;
  385. }
  386. return ret;
  387. }
  388. int iwm_send_packet(struct iwm_priv *iwm, struct sk_buff *skb, int pool_id)
  389. {
  390. struct iwm_udma_wifi_cmd udma_cmd;
  391. struct iwm_umac_cmd umac_cmd;
  392. struct iwm_tx_info *tx_info = skb_to_tx_info(skb);
  393. udma_cmd.eop = 1; /* always set eop for non-concatenated Tx */
  394. udma_cmd.credit_group = pool_id;
  395. udma_cmd.ra_tid = tx_info->sta << 4 | tx_info->tid;
  396. udma_cmd.lmac_offset = 0;
  397. umac_cmd.id = REPLY_TX;
  398. umac_cmd.color = tx_info->color;
  399. umac_cmd.resp = 0;
  400. return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd,
  401. skb->data, skb->len);
  402. }
  403. static int iwm_target_read(struct iwm_priv *iwm, __le32 address,
  404. u8 *response, u32 resp_size)
  405. {
  406. struct iwm_udma_nonwifi_cmd target_cmd;
  407. struct iwm_nonwifi_cmd *cmd;
  408. u16 seq_num;
  409. int ret = 0;
  410. target_cmd.opcode = UMAC_HDI_OUT_OPCODE_READ;
  411. target_cmd.addr = address;
  412. target_cmd.op1_sz = cpu_to_le32(resp_size);
  413. target_cmd.op2 = 0;
  414. target_cmd.handle_by_hw = 0;
  415. target_cmd.resp = 1;
  416. target_cmd.eop = 1;
  417. ret = iwm_hal_send_target_cmd(iwm, &target_cmd, NULL);
  418. if (ret < 0) {
  419. IWM_ERR(iwm, "Couldn't send READ command\n");
  420. return ret;
  421. }
  422. /* When succeeding, the send_target routine returns the seq number */
  423. seq_num = ret;
  424. ret = wait_event_interruptible_timeout(iwm->nonwifi_queue,
  425. (cmd = iwm_get_pending_nonwifi_cmd(iwm, seq_num,
  426. UMAC_HDI_OUT_OPCODE_READ)) != NULL,
  427. 2 * HZ);
  428. if (!ret) {
  429. IWM_ERR(iwm, "Didn't receive a target READ answer\n");
  430. return ret;
  431. }
  432. memcpy(response, cmd->buf.hdr + sizeof(struct iwm_udma_in_hdr),
  433. resp_size);
  434. kfree(cmd);
  435. return 0;
  436. }
  437. int iwm_read_mac(struct iwm_priv *iwm, u8 *mac)
  438. {
  439. int ret;
  440. u8 mac_align[ALIGN(ETH_ALEN, 8)];
  441. ret = iwm_target_read(iwm, cpu_to_le32(WICO_MAC_ADDRESS_ADDR),
  442. mac_align, sizeof(mac_align));
  443. if (ret)
  444. return ret;
  445. if (is_valid_ether_addr(mac_align))
  446. memcpy(mac, mac_align, ETH_ALEN);
  447. else {
  448. IWM_ERR(iwm, "Invalid EEPROM MAC\n");
  449. memcpy(mac, iwm->conf.mac_addr, ETH_ALEN);
  450. get_random_bytes(&mac[3], 3);
  451. }
  452. return 0;
  453. }
  454. static int iwm_check_profile(struct iwm_priv *iwm)
  455. {
  456. if (!iwm->umac_profile_active)
  457. return -EAGAIN;
  458. if (iwm->umac_profile->sec.ucast_cipher != UMAC_CIPHER_TYPE_WEP_40 &&
  459. iwm->umac_profile->sec.ucast_cipher != UMAC_CIPHER_TYPE_WEP_104 &&
  460. iwm->umac_profile->sec.ucast_cipher != UMAC_CIPHER_TYPE_TKIP &&
  461. iwm->umac_profile->sec.ucast_cipher != UMAC_CIPHER_TYPE_CCMP) {
  462. IWM_ERR(iwm, "Wrong unicast cipher: 0x%x\n",
  463. iwm->umac_profile->sec.ucast_cipher);
  464. return -EAGAIN;
  465. }
  466. if (iwm->umac_profile->sec.mcast_cipher != UMAC_CIPHER_TYPE_WEP_40 &&
  467. iwm->umac_profile->sec.mcast_cipher != UMAC_CIPHER_TYPE_WEP_104 &&
  468. iwm->umac_profile->sec.mcast_cipher != UMAC_CIPHER_TYPE_TKIP &&
  469. iwm->umac_profile->sec.mcast_cipher != UMAC_CIPHER_TYPE_CCMP) {
  470. IWM_ERR(iwm, "Wrong multicast cipher: 0x%x\n",
  471. iwm->umac_profile->sec.mcast_cipher);
  472. return -EAGAIN;
  473. }
  474. if ((iwm->umac_profile->sec.ucast_cipher == UMAC_CIPHER_TYPE_WEP_40 ||
  475. iwm->umac_profile->sec.ucast_cipher == UMAC_CIPHER_TYPE_WEP_104) &&
  476. (iwm->umac_profile->sec.ucast_cipher !=
  477. iwm->umac_profile->sec.mcast_cipher)) {
  478. IWM_ERR(iwm, "Unicast and multicast ciphers differ for WEP\n");
  479. }
  480. return 0;
  481. }
  482. int iwm_set_tx_key(struct iwm_priv *iwm, u8 key_idx)
  483. {
  484. struct iwm_umac_tx_key_id tx_key_id;
  485. int ret;
  486. ret = iwm_check_profile(iwm);
  487. if (ret < 0)
  488. return ret;
  489. /* UMAC only allows to set default key for WEP and auth type is
  490. * NOT 802.1X or RSNA. */
  491. if ((iwm->umac_profile->sec.ucast_cipher != UMAC_CIPHER_TYPE_WEP_40 &&
  492. iwm->umac_profile->sec.ucast_cipher != UMAC_CIPHER_TYPE_WEP_104) ||
  493. iwm->umac_profile->sec.auth_type == UMAC_AUTH_TYPE_8021X ||
  494. iwm->umac_profile->sec.auth_type == UMAC_AUTH_TYPE_RSNA_PSK)
  495. return 0;
  496. tx_key_id.hdr.oid = UMAC_WIFI_IF_CMD_GLOBAL_TX_KEY_ID;
  497. tx_key_id.hdr.buf_size = cpu_to_le16(sizeof(struct iwm_umac_tx_key_id) -
  498. sizeof(struct iwm_umac_wifi_if));
  499. tx_key_id.key_idx = key_idx;
  500. return iwm_send_wifi_if_cmd(iwm, &tx_key_id, sizeof(tx_key_id), 1);
  501. }
  502. int iwm_set_key(struct iwm_priv *iwm, bool remove, struct iwm_key *key)
  503. {
  504. int ret = 0;
  505. u8 cmd[64], *sta_addr, *key_data, key_len;
  506. s8 key_idx;
  507. u16 cmd_size = 0;
  508. struct iwm_umac_key_hdr *key_hdr = &key->hdr;
  509. struct iwm_umac_key_wep40 *wep40 = (struct iwm_umac_key_wep40 *)cmd;
  510. struct iwm_umac_key_wep104 *wep104 = (struct iwm_umac_key_wep104 *)cmd;
  511. struct iwm_umac_key_tkip *tkip = (struct iwm_umac_key_tkip *)cmd;
  512. struct iwm_umac_key_ccmp *ccmp = (struct iwm_umac_key_ccmp *)cmd;
  513. if (!remove) {
  514. ret = iwm_check_profile(iwm);
  515. if (ret < 0)
  516. return ret;
  517. }
  518. sta_addr = key->hdr.mac;
  519. key_data = key->key;
  520. key_len = key->key_len;
  521. key_idx = key->hdr.key_idx;
  522. if (!remove) {
  523. u8 auth_type = iwm->umac_profile->sec.auth_type;
  524. IWM_DBG_WEXT(iwm, DBG, "key_idx:%d\n", key_idx);
  525. IWM_DBG_WEXT(iwm, DBG, "key_len:%d\n", key_len);
  526. IWM_DBG_WEXT(iwm, DBG, "MAC:%pM, idx:%d, multicast:%d\n",
  527. key_hdr->mac, key_hdr->key_idx, key_hdr->multicast);
  528. IWM_DBG_WEXT(iwm, DBG, "profile: mcast:0x%x, ucast:0x%x\n",
  529. iwm->umac_profile->sec.mcast_cipher,
  530. iwm->umac_profile->sec.ucast_cipher);
  531. IWM_DBG_WEXT(iwm, DBG, "profile: auth_type:0x%x, flags:0x%x\n",
  532. iwm->umac_profile->sec.auth_type,
  533. iwm->umac_profile->sec.flags);
  534. switch (key->cipher) {
  535. case WLAN_CIPHER_SUITE_WEP40:
  536. wep40->hdr.oid = UMAC_WIFI_IF_CMD_ADD_WEP40_KEY;
  537. wep40->hdr.buf_size =
  538. cpu_to_le16(sizeof(struct iwm_umac_key_wep40) -
  539. sizeof(struct iwm_umac_wifi_if));
  540. memcpy(&wep40->key_hdr, key_hdr,
  541. sizeof(struct iwm_umac_key_hdr));
  542. memcpy(wep40->key, key_data, key_len);
  543. wep40->static_key =
  544. !!((auth_type != UMAC_AUTH_TYPE_8021X) &&
  545. (auth_type != UMAC_AUTH_TYPE_RSNA_PSK));
  546. cmd_size = sizeof(struct iwm_umac_key_wep40);
  547. break;
  548. case WLAN_CIPHER_SUITE_WEP104:
  549. wep104->hdr.oid = UMAC_WIFI_IF_CMD_ADD_WEP104_KEY;
  550. wep104->hdr.buf_size =
  551. cpu_to_le16(sizeof(struct iwm_umac_key_wep104) -
  552. sizeof(struct iwm_umac_wifi_if));
  553. memcpy(&wep104->key_hdr, key_hdr,
  554. sizeof(struct iwm_umac_key_hdr));
  555. memcpy(wep104->key, key_data, key_len);
  556. wep104->static_key =
  557. !!((auth_type != UMAC_AUTH_TYPE_8021X) &&
  558. (auth_type != UMAC_AUTH_TYPE_RSNA_PSK));
  559. cmd_size = sizeof(struct iwm_umac_key_wep104);
  560. break;
  561. case WLAN_CIPHER_SUITE_CCMP:
  562. key_hdr->key_idx++;
  563. ccmp->hdr.oid = UMAC_WIFI_IF_CMD_ADD_CCMP_KEY;
  564. ccmp->hdr.buf_size =
  565. cpu_to_le16(sizeof(struct iwm_umac_key_ccmp) -
  566. sizeof(struct iwm_umac_wifi_if));
  567. memcpy(&ccmp->key_hdr, key_hdr,
  568. sizeof(struct iwm_umac_key_hdr));
  569. memcpy(ccmp->key, key_data, key_len);
  570. if (key->seq_len)
  571. memcpy(ccmp->iv_count, key->seq, key->seq_len);
  572. cmd_size = sizeof(struct iwm_umac_key_ccmp);
  573. break;
  574. case WLAN_CIPHER_SUITE_TKIP:
  575. key_hdr->key_idx++;
  576. tkip->hdr.oid = UMAC_WIFI_IF_CMD_ADD_TKIP_KEY;
  577. tkip->hdr.buf_size =
  578. cpu_to_le16(sizeof(struct iwm_umac_key_tkip) -
  579. sizeof(struct iwm_umac_wifi_if));
  580. memcpy(&tkip->key_hdr, key_hdr,
  581. sizeof(struct iwm_umac_key_hdr));
  582. memcpy(tkip->tkip_key, key_data, IWM_TKIP_KEY_SIZE);
  583. memcpy(tkip->mic_tx_key, key_data + IWM_TKIP_KEY_SIZE,
  584. IWM_TKIP_MIC_SIZE);
  585. memcpy(tkip->mic_rx_key,
  586. key_data + IWM_TKIP_KEY_SIZE + IWM_TKIP_MIC_SIZE,
  587. IWM_TKIP_MIC_SIZE);
  588. if (key->seq_len)
  589. memcpy(ccmp->iv_count, key->seq, key->seq_len);
  590. cmd_size = sizeof(struct iwm_umac_key_tkip);
  591. break;
  592. default:
  593. return -ENOTSUPP;
  594. }
  595. if ((key->cipher == WLAN_CIPHER_SUITE_TKIP) ||
  596. (key->cipher == WLAN_CIPHER_SUITE_CCMP))
  597. /*
  598. * UGLY_UGLY_UGLY
  599. * Copied HACK from the MWG driver.
  600. * Without it, the key is set before the second
  601. * EAPOL frame is sent, and the latter is thus
  602. * encrypted.
  603. */
  604. schedule_timeout_interruptible(usecs_to_jiffies(300));
  605. ret = iwm_send_wifi_if_cmd(iwm, cmd, cmd_size, 1);
  606. } else {
  607. struct iwm_umac_key_remove key_remove;
  608. IWM_DBG_WEXT(iwm, ERR, "Removing key_idx:%d\n", key_idx);
  609. key_remove.hdr.oid = UMAC_WIFI_IF_CMD_REMOVE_KEY;
  610. key_remove.hdr.buf_size =
  611. cpu_to_le16(sizeof(struct iwm_umac_key_remove) -
  612. sizeof(struct iwm_umac_wifi_if));
  613. memcpy(&key_remove.key_hdr, key_hdr,
  614. sizeof(struct iwm_umac_key_hdr));
  615. ret = iwm_send_wifi_if_cmd(iwm, &key_remove,
  616. sizeof(struct iwm_umac_key_remove),
  617. 1);
  618. if (ret)
  619. return ret;
  620. iwm->keys[key_idx].key_len = 0;
  621. }
  622. return ret;
  623. }
  624. int iwm_send_mlme_profile(struct iwm_priv *iwm)
  625. {
  626. int ret;
  627. struct iwm_umac_profile profile;
  628. memcpy(&profile, iwm->umac_profile, sizeof(profile));
  629. profile.hdr.oid = UMAC_WIFI_IF_CMD_SET_PROFILE;
  630. profile.hdr.buf_size = cpu_to_le16(sizeof(struct iwm_umac_profile) -
  631. sizeof(struct iwm_umac_wifi_if));
  632. ret = iwm_send_wifi_if_cmd(iwm, &profile, sizeof(profile), 1);
  633. if (ret) {
  634. IWM_ERR(iwm, "Send profile command failed\n");
  635. return ret;
  636. }
  637. set_bit(IWM_STATUS_SME_CONNECTING, &iwm->status);
  638. return 0;
  639. }
  640. int __iwm_invalidate_mlme_profile(struct iwm_priv *iwm)
  641. {
  642. struct iwm_umac_invalidate_profile invalid;
  643. invalid.hdr.oid = UMAC_WIFI_IF_CMD_INVALIDATE_PROFILE;
  644. invalid.hdr.buf_size =
  645. cpu_to_le16(sizeof(struct iwm_umac_invalidate_profile) -
  646. sizeof(struct iwm_umac_wifi_if));
  647. invalid.reason = WLAN_REASON_UNSPECIFIED;
  648. return iwm_send_wifi_if_cmd(iwm, &invalid, sizeof(invalid), 1);
  649. }
  650. int iwm_invalidate_mlme_profile(struct iwm_priv *iwm)
  651. {
  652. int ret;
  653. ret = __iwm_invalidate_mlme_profile(iwm);
  654. if (ret)
  655. return ret;
  656. ret = wait_event_interruptible_timeout(iwm->mlme_queue,
  657. (iwm->umac_profile_active == 0), 5 * HZ);
  658. return ret ? 0 : -EBUSY;
  659. }
  660. int iwm_tx_power_trigger(struct iwm_priv *iwm)
  661. {
  662. struct iwm_umac_pwr_trigger pwr_trigger;
  663. pwr_trigger.hdr.oid = UMAC_WIFI_IF_CMD_TX_PWR_TRIGGER;
  664. pwr_trigger.hdr.buf_size =
  665. cpu_to_le16(sizeof(struct iwm_umac_pwr_trigger) -
  666. sizeof(struct iwm_umac_wifi_if));
  667. return iwm_send_wifi_if_cmd(iwm, &pwr_trigger, sizeof(pwr_trigger), 1);
  668. }
  669. int iwm_send_umac_stats_req(struct iwm_priv *iwm, u32 flags)
  670. {
  671. struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
  672. struct iwm_umac_cmd umac_cmd;
  673. struct iwm_umac_cmd_stats_req stats_req;
  674. stats_req.flags = cpu_to_le32(flags);
  675. umac_cmd.id = UMAC_CMD_OPCODE_STATISTIC_REQUEST;
  676. umac_cmd.resp = 0;
  677. return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, &stats_req,
  678. sizeof(struct iwm_umac_cmd_stats_req));
  679. }
  680. int iwm_send_umac_channel_list(struct iwm_priv *iwm)
  681. {
  682. struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
  683. struct iwm_umac_cmd umac_cmd;
  684. struct iwm_umac_cmd_get_channel_list *ch_list;
  685. int size = sizeof(struct iwm_umac_cmd_get_channel_list) +
  686. sizeof(struct iwm_umac_channel_info) * 4;
  687. int ret;
  688. ch_list = kzalloc(size, GFP_KERNEL);
  689. if (!ch_list) {
  690. IWM_ERR(iwm, "Couldn't allocate channel list cmd\n");
  691. return -ENOMEM;
  692. }
  693. ch_list->ch[0].band = UMAC_BAND_2GHZ;
  694. ch_list->ch[0].type = UMAC_CHANNEL_WIDTH_20MHZ;
  695. ch_list->ch[0].flags = UMAC_CHANNEL_FLAG_VALID;
  696. ch_list->ch[1].band = UMAC_BAND_5GHZ;
  697. ch_list->ch[1].type = UMAC_CHANNEL_WIDTH_20MHZ;
  698. ch_list->ch[1].flags = UMAC_CHANNEL_FLAG_VALID;
  699. ch_list->ch[2].band = UMAC_BAND_2GHZ;
  700. ch_list->ch[2].type = UMAC_CHANNEL_WIDTH_20MHZ;
  701. ch_list->ch[2].flags = UMAC_CHANNEL_FLAG_VALID | UMAC_CHANNEL_FLAG_IBSS;
  702. ch_list->ch[3].band = UMAC_BAND_5GHZ;
  703. ch_list->ch[3].type = UMAC_CHANNEL_WIDTH_20MHZ;
  704. ch_list->ch[3].flags = UMAC_CHANNEL_FLAG_VALID | UMAC_CHANNEL_FLAG_IBSS;
  705. ch_list->count = cpu_to_le16(4);
  706. umac_cmd.id = UMAC_CMD_OPCODE_GET_CHAN_INFO_LIST;
  707. umac_cmd.resp = 1;
  708. ret = iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, ch_list, size);
  709. kfree(ch_list);
  710. return ret;
  711. }
  712. int iwm_scan_ssids(struct iwm_priv *iwm, struct cfg80211_ssid *ssids,
  713. int ssid_num)
  714. {
  715. struct iwm_umac_cmd_scan_request req;
  716. int i, ret;
  717. memset(&req, 0, sizeof(struct iwm_umac_cmd_scan_request));
  718. req.hdr.oid = UMAC_WIFI_IF_CMD_SCAN_REQUEST;
  719. req.hdr.buf_size = cpu_to_le16(sizeof(struct iwm_umac_cmd_scan_request)
  720. - sizeof(struct iwm_umac_wifi_if));
  721. req.type = UMAC_WIFI_IF_SCAN_TYPE_USER;
  722. req.timeout = 2;
  723. req.seq_num = iwm->scan_id;
  724. req.ssid_num = min(ssid_num, UMAC_WIFI_IF_PROBE_OPTION_MAX);
  725. for (i = 0; i < req.ssid_num; i++) {
  726. memcpy(req.ssids[i].ssid, ssids[i].ssid, ssids[i].ssid_len);
  727. req.ssids[i].ssid_len = ssids[i].ssid_len;
  728. }
  729. ret = iwm_send_wifi_if_cmd(iwm, &req, sizeof(req), 0);
  730. if (ret) {
  731. IWM_ERR(iwm, "Couldn't send scan request\n");
  732. return ret;
  733. }
  734. iwm->scan_id = iwm->scan_id++ % IWM_SCAN_ID_MAX;
  735. return 0;
  736. }
  737. int iwm_scan_one_ssid(struct iwm_priv *iwm, u8 *ssid, int ssid_len)
  738. {
  739. struct cfg80211_ssid one_ssid;
  740. if (test_and_set_bit(IWM_STATUS_SCANNING, &iwm->status))
  741. return 0;
  742. one_ssid.ssid_len = min(ssid_len, IEEE80211_MAX_SSID_LEN);
  743. memcpy(&one_ssid.ssid, ssid, one_ssid.ssid_len);
  744. return iwm_scan_ssids(iwm, &one_ssid, 1);
  745. }
  746. int iwm_target_reset(struct iwm_priv *iwm)
  747. {
  748. struct iwm_udma_nonwifi_cmd target_cmd;
  749. target_cmd.opcode = UMAC_HDI_OUT_OPCODE_REBOOT;
  750. target_cmd.addr = 0;
  751. target_cmd.op1_sz = 0;
  752. target_cmd.op2 = 0;
  753. target_cmd.handle_by_hw = 0;
  754. target_cmd.resp = 0;
  755. target_cmd.eop = 1;
  756. return iwm_hal_send_target_cmd(iwm, &target_cmd, NULL);
  757. }
  758. int iwm_send_umac_stop_resume_tx(struct iwm_priv *iwm,
  759. struct iwm_umac_notif_stop_resume_tx *ntf)
  760. {
  761. struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT;
  762. struct iwm_umac_cmd umac_cmd;
  763. struct iwm_umac_cmd_stop_resume_tx stp_res_cmd;
  764. struct iwm_sta_info *sta_info;
  765. u8 sta_id = STA_ID_N_COLOR_ID(ntf->sta_id);
  766. int i;
  767. sta_info = &iwm->sta_table[sta_id];
  768. if (!sta_info->valid) {
  769. IWM_ERR(iwm, "Invalid STA: %d\n", sta_id);
  770. return -EINVAL;
  771. }
  772. umac_cmd.id = UMAC_CMD_OPCODE_STOP_RESUME_STA_TX;
  773. umac_cmd.resp = 0;
  774. stp_res_cmd.flags = ntf->flags;
  775. stp_res_cmd.sta_id = ntf->sta_id;
  776. stp_res_cmd.stop_resume_tid_msk = ntf->stop_resume_tid_msk;
  777. for (i = 0; i < IWM_UMAC_TID_NR; i++)
  778. stp_res_cmd.last_seq_num[i] =
  779. sta_info->tid_info[i].last_seq_num;
  780. return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, &stp_res_cmd,
  781. sizeof(struct iwm_umac_cmd_stop_resume_tx));
  782. }
  783. int iwm_send_pmkid_update(struct iwm_priv *iwm,
  784. struct cfg80211_pmksa *pmksa, u32 command)
  785. {
  786. struct iwm_umac_pmkid_update update;
  787. int ret;
  788. memset(&update, 0, sizeof(struct iwm_umac_pmkid_update));
  789. update.hdr.oid = UMAC_WIFI_IF_CMD_PMKID_UPDATE;
  790. update.hdr.buf_size = cpu_to_le16(sizeof(struct iwm_umac_pmkid_update) -
  791. sizeof(struct iwm_umac_wifi_if));
  792. update.command = cpu_to_le32(command);
  793. if (pmksa->bssid)
  794. memcpy(&update.bssid, pmksa->bssid, ETH_ALEN);
  795. if (pmksa->pmkid)
  796. memcpy(&update.pmkid, pmksa->pmkid, WLAN_PMKID_LEN);
  797. ret = iwm_send_wifi_if_cmd(iwm, &update,
  798. sizeof(struct iwm_umac_pmkid_update), 0);
  799. if (ret) {
  800. IWM_ERR(iwm, "PMKID update command failed\n");
  801. return ret;
  802. }
  803. return 0;
  804. }