cmdresp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /**
  2. * This file contains the handling of command
  3. * responses as well as events generated by firmware.
  4. */
  5. #include <linux/delay.h>
  6. #include <linux/sched.h>
  7. #include <linux/if_arp.h>
  8. #include <linux/netdevice.h>
  9. #include <asm/unaligned.h>
  10. #include <net/iw_handler.h>
  11. #include "host.h"
  12. #include "decl.h"
  13. #include "cmd.h"
  14. #include "defs.h"
  15. #include "dev.h"
  16. #include "assoc.h"
  17. #include "wext.h"
  18. /**
  19. * @brief This function handles disconnect event. it
  20. * reports disconnect to upper layer, clean tx/rx packets,
  21. * reset link state etc.
  22. *
  23. * @param priv A pointer to struct lbs_private structure
  24. * @return n/a
  25. */
  26. void lbs_mac_event_disconnected(struct lbs_private *priv)
  27. {
  28. union iwreq_data wrqu;
  29. if (priv->connect_status != LBS_CONNECTED)
  30. return;
  31. lbs_deb_enter(LBS_DEB_ASSOC);
  32. memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN);
  33. wrqu.ap_addr.sa_family = ARPHRD_ETHER;
  34. /*
  35. * Cisco AP sends EAP failure and de-auth in less than 0.5 ms.
  36. * It causes problem in the Supplicant
  37. */
  38. msleep_interruptible(1000);
  39. wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
  40. /* report disconnect to upper layer */
  41. netif_stop_queue(priv->dev);
  42. netif_carrier_off(priv->dev);
  43. /* Free Tx and Rx packets */
  44. kfree_skb(priv->currenttxskb);
  45. priv->currenttxskb = NULL;
  46. priv->tx_pending_len = 0;
  47. /* reset SNR/NF/RSSI values */
  48. memset(priv->SNR, 0x00, sizeof(priv->SNR));
  49. memset(priv->NF, 0x00, sizeof(priv->NF));
  50. memset(priv->RSSI, 0x00, sizeof(priv->RSSI));
  51. memset(priv->rawSNR, 0x00, sizeof(priv->rawSNR));
  52. memset(priv->rawNF, 0x00, sizeof(priv->rawNF));
  53. priv->nextSNRNF = 0;
  54. priv->numSNRNF = 0;
  55. priv->connect_status = LBS_DISCONNECTED;
  56. /* Clear out associated SSID and BSSID since connection is
  57. * no longer valid.
  58. */
  59. memset(&priv->curbssparams.bssid, 0, ETH_ALEN);
  60. memset(&priv->curbssparams.ssid, 0, IEEE80211_MAX_SSID_LEN);
  61. priv->curbssparams.ssid_len = 0;
  62. if (priv->psstate != PS_STATE_FULL_POWER) {
  63. /* make firmware to exit PS mode */
  64. lbs_deb_cmd("disconnected, so exit PS mode\n");
  65. lbs_ps_wakeup(priv, 0);
  66. }
  67. lbs_deb_leave(LBS_DEB_ASSOC);
  68. }
  69. /**
  70. * @brief This function handles MIC failure event.
  71. *
  72. * @param priv A pointer to struct lbs_private structure
  73. * @para event the event id
  74. * @return n/a
  75. */
  76. static void handle_mic_failureevent(struct lbs_private *priv, u32 event)
  77. {
  78. char buf[50];
  79. lbs_deb_enter(LBS_DEB_CMD);
  80. memset(buf, 0, sizeof(buf));
  81. sprintf(buf, "%s", "MLME-MICHAELMICFAILURE.indication ");
  82. if (event == MACREG_INT_CODE_MIC_ERR_UNICAST) {
  83. strcat(buf, "unicast ");
  84. } else {
  85. strcat(buf, "multicast ");
  86. }
  87. lbs_send_iwevcustom_event(priv, buf);
  88. lbs_deb_leave(LBS_DEB_CMD);
  89. }
  90. static int lbs_ret_reg_access(struct lbs_private *priv,
  91. u16 type, struct cmd_ds_command *resp)
  92. {
  93. int ret = 0;
  94. lbs_deb_enter(LBS_DEB_CMD);
  95. switch (type) {
  96. case CMD_RET(CMD_MAC_REG_ACCESS):
  97. {
  98. struct cmd_ds_mac_reg_access *reg = &resp->params.macreg;
  99. priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
  100. priv->offsetvalue.value = le32_to_cpu(reg->value);
  101. break;
  102. }
  103. case CMD_RET(CMD_BBP_REG_ACCESS):
  104. {
  105. struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg;
  106. priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
  107. priv->offsetvalue.value = reg->value;
  108. break;
  109. }
  110. case CMD_RET(CMD_RF_REG_ACCESS):
  111. {
  112. struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg;
  113. priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
  114. priv->offsetvalue.value = reg->value;
  115. break;
  116. }
  117. default:
  118. ret = -1;
  119. }
  120. lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
  121. return ret;
  122. }
  123. static int lbs_ret_802_11_rssi(struct lbs_private *priv,
  124. struct cmd_ds_command *resp)
  125. {
  126. struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp;
  127. lbs_deb_enter(LBS_DEB_CMD);
  128. /* store the non average value */
  129. priv->SNR[TYPE_BEACON][TYPE_NOAVG] = get_unaligned_le16(&rssirsp->SNR);
  130. priv->NF[TYPE_BEACON][TYPE_NOAVG] = get_unaligned_le16(&rssirsp->noisefloor);
  131. priv->SNR[TYPE_BEACON][TYPE_AVG] = get_unaligned_le16(&rssirsp->avgSNR);
  132. priv->NF[TYPE_BEACON][TYPE_AVG] = get_unaligned_le16(&rssirsp->avgnoisefloor);
  133. priv->RSSI[TYPE_BEACON][TYPE_NOAVG] =
  134. CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
  135. priv->NF[TYPE_BEACON][TYPE_NOAVG]);
  136. priv->RSSI[TYPE_BEACON][TYPE_AVG] =
  137. CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_AVG] / AVG_SCALE,
  138. priv->NF[TYPE_BEACON][TYPE_AVG] / AVG_SCALE);
  139. lbs_deb_cmd("RSSI: beacon %d, avg %d\n",
  140. priv->RSSI[TYPE_BEACON][TYPE_NOAVG],
  141. priv->RSSI[TYPE_BEACON][TYPE_AVG]);
  142. lbs_deb_leave(LBS_DEB_CMD);
  143. return 0;
  144. }
  145. static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv,
  146. struct cmd_ds_command *resp)
  147. {
  148. struct cmd_ds_802_11_beacon_control *bcn_ctrl =
  149. &resp->params.bcn_ctrl;
  150. lbs_deb_enter(LBS_DEB_CMD);
  151. if (bcn_ctrl->action == CMD_ACT_GET) {
  152. priv->beacon_enable = (u8) le16_to_cpu(bcn_ctrl->beacon_enable);
  153. priv->beacon_period = le16_to_cpu(bcn_ctrl->beacon_period);
  154. }
  155. lbs_deb_enter(LBS_DEB_CMD);
  156. return 0;
  157. }
  158. static inline int handle_cmd_response(struct lbs_private *priv,
  159. struct cmd_header *cmd_response)
  160. {
  161. struct cmd_ds_command *resp = (struct cmd_ds_command *) cmd_response;
  162. int ret = 0;
  163. unsigned long flags;
  164. uint16_t respcmd = le16_to_cpu(resp->command);
  165. lbs_deb_enter(LBS_DEB_HOST);
  166. switch (respcmd) {
  167. case CMD_RET(CMD_MAC_REG_ACCESS):
  168. case CMD_RET(CMD_BBP_REG_ACCESS):
  169. case CMD_RET(CMD_RF_REG_ACCESS):
  170. ret = lbs_ret_reg_access(priv, respcmd, resp);
  171. break;
  172. case CMD_RET(CMD_802_11_SET_AFC):
  173. case CMD_RET(CMD_802_11_GET_AFC):
  174. spin_lock_irqsave(&priv->driver_lock, flags);
  175. memmove((void *)priv->cur_cmd->callback_arg, &resp->params.afc,
  176. sizeof(struct cmd_ds_802_11_afc));
  177. spin_unlock_irqrestore(&priv->driver_lock, flags);
  178. break;
  179. case CMD_RET(CMD_802_11_BEACON_STOP):
  180. break;
  181. case CMD_RET(CMD_802_11_RSSI):
  182. ret = lbs_ret_802_11_rssi(priv, resp);
  183. break;
  184. case CMD_RET(CMD_802_11_TPC_CFG):
  185. spin_lock_irqsave(&priv->driver_lock, flags);
  186. memmove((void *)priv->cur_cmd->callback_arg, &resp->params.tpccfg,
  187. sizeof(struct cmd_ds_802_11_tpc_cfg));
  188. spin_unlock_irqrestore(&priv->driver_lock, flags);
  189. break;
  190. case CMD_RET(CMD_802_11_LED_GPIO_CTRL):
  191. spin_lock_irqsave(&priv->driver_lock, flags);
  192. memmove((void *)priv->cur_cmd->callback_arg, &resp->params.ledgpio,
  193. sizeof(struct cmd_ds_802_11_led_ctrl));
  194. spin_unlock_irqrestore(&priv->driver_lock, flags);
  195. break;
  196. case CMD_RET(CMD_GET_TSF):
  197. spin_lock_irqsave(&priv->driver_lock, flags);
  198. memcpy((void *)priv->cur_cmd->callback_arg,
  199. &resp->params.gettsf.tsfvalue, sizeof(u64));
  200. spin_unlock_irqrestore(&priv->driver_lock, flags);
  201. break;
  202. case CMD_RET(CMD_BT_ACCESS):
  203. spin_lock_irqsave(&priv->driver_lock, flags);
  204. if (priv->cur_cmd->callback_arg)
  205. memcpy((void *)priv->cur_cmd->callback_arg,
  206. &resp->params.bt.addr1, 2 * ETH_ALEN);
  207. spin_unlock_irqrestore(&priv->driver_lock, flags);
  208. break;
  209. case CMD_RET(CMD_FWT_ACCESS):
  210. spin_lock_irqsave(&priv->driver_lock, flags);
  211. if (priv->cur_cmd->callback_arg)
  212. memcpy((void *)priv->cur_cmd->callback_arg, &resp->params.fwt,
  213. sizeof(resp->params.fwt));
  214. spin_unlock_irqrestore(&priv->driver_lock, flags);
  215. break;
  216. case CMD_RET(CMD_802_11_BEACON_CTRL):
  217. ret = lbs_ret_802_11_bcn_ctrl(priv, resp);
  218. break;
  219. default:
  220. lbs_pr_err("CMD_RESP: unknown cmd response 0x%04x\n",
  221. le16_to_cpu(resp->command));
  222. break;
  223. }
  224. lbs_deb_leave(LBS_DEB_HOST);
  225. return ret;
  226. }
  227. int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
  228. {
  229. uint16_t respcmd, curcmd;
  230. struct cmd_header *resp;
  231. int ret = 0;
  232. unsigned long flags;
  233. uint16_t result;
  234. lbs_deb_enter(LBS_DEB_HOST);
  235. mutex_lock(&priv->lock);
  236. spin_lock_irqsave(&priv->driver_lock, flags);
  237. if (!priv->cur_cmd) {
  238. lbs_deb_host("CMD_RESP: cur_cmd is NULL\n");
  239. ret = -1;
  240. spin_unlock_irqrestore(&priv->driver_lock, flags);
  241. goto done;
  242. }
  243. resp = (void *)data;
  244. curcmd = le16_to_cpu(priv->cur_cmd->cmdbuf->command);
  245. respcmd = le16_to_cpu(resp->command);
  246. result = le16_to_cpu(resp->result);
  247. lbs_deb_cmd("CMD_RESP: response 0x%04x, seq %d, size %d\n",
  248. respcmd, le16_to_cpu(resp->seqnum), len);
  249. lbs_deb_hex(LBS_DEB_CMD, "CMD_RESP", (void *) resp, len);
  250. if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) {
  251. lbs_pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n",
  252. le16_to_cpu(resp->seqnum), le16_to_cpu(priv->cur_cmd->cmdbuf->seqnum));
  253. spin_unlock_irqrestore(&priv->driver_lock, flags);
  254. ret = -1;
  255. goto done;
  256. }
  257. if (respcmd != CMD_RET(curcmd) &&
  258. respcmd != CMD_RET_802_11_ASSOCIATE && curcmd != CMD_802_11_ASSOCIATE) {
  259. lbs_pr_info("Invalid CMD_RESP %x to command %x!\n", respcmd, curcmd);
  260. spin_unlock_irqrestore(&priv->driver_lock, flags);
  261. ret = -1;
  262. goto done;
  263. }
  264. if (resp->result == cpu_to_le16(0x0004)) {
  265. /* 0x0004 means -EAGAIN. Drop the response, let it time out
  266. and be resubmitted */
  267. lbs_pr_info("Firmware returns DEFER to command %x. Will let it time out...\n",
  268. le16_to_cpu(resp->command));
  269. spin_unlock_irqrestore(&priv->driver_lock, flags);
  270. ret = -1;
  271. goto done;
  272. }
  273. /* Now we got response from FW, cancel the command timer */
  274. del_timer(&priv->command_timer);
  275. priv->cmd_timed_out = 0;
  276. if (priv->nr_retries) {
  277. lbs_pr_info("Received result %x to command %x after %d retries\n",
  278. result, curcmd, priv->nr_retries);
  279. priv->nr_retries = 0;
  280. }
  281. /* Store the response code to cur_cmd_retcode. */
  282. priv->cur_cmd_retcode = result;
  283. if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) {
  284. struct cmd_ds_802_11_ps_mode *psmode = (void *) &resp[1];
  285. u16 action = le16_to_cpu(psmode->action);
  286. lbs_deb_host(
  287. "CMD_RESP: PS_MODE cmd reply result 0x%x, action 0x%x\n",
  288. result, action);
  289. if (result) {
  290. lbs_deb_host("CMD_RESP: PS command failed with 0x%x\n",
  291. result);
  292. /*
  293. * We should not re-try enter-ps command in
  294. * ad-hoc mode. It takes place in
  295. * lbs_execute_next_command().
  296. */
  297. if (priv->mode == IW_MODE_ADHOC &&
  298. action == CMD_SUBCMD_ENTER_PS)
  299. priv->psmode = LBS802_11POWERMODECAM;
  300. } else if (action == CMD_SUBCMD_ENTER_PS) {
  301. priv->needtowakeup = 0;
  302. priv->psstate = PS_STATE_AWAKE;
  303. lbs_deb_host("CMD_RESP: ENTER_PS command response\n");
  304. if (priv->connect_status != LBS_CONNECTED) {
  305. /*
  306. * When Deauth Event received before Enter_PS command
  307. * response, We need to wake up the firmware.
  308. */
  309. lbs_deb_host(
  310. "disconnected, invoking lbs_ps_wakeup\n");
  311. spin_unlock_irqrestore(&priv->driver_lock, flags);
  312. mutex_unlock(&priv->lock);
  313. lbs_ps_wakeup(priv, 0);
  314. mutex_lock(&priv->lock);
  315. spin_lock_irqsave(&priv->driver_lock, flags);
  316. }
  317. } else if (action == CMD_SUBCMD_EXIT_PS) {
  318. priv->needtowakeup = 0;
  319. priv->psstate = PS_STATE_FULL_POWER;
  320. lbs_deb_host("CMD_RESP: EXIT_PS command response\n");
  321. } else {
  322. lbs_deb_host("CMD_RESP: PS action 0x%X\n", action);
  323. }
  324. lbs_complete_command(priv, priv->cur_cmd, result);
  325. spin_unlock_irqrestore(&priv->driver_lock, flags);
  326. ret = 0;
  327. goto done;
  328. }
  329. /* If the command is not successful, cleanup and return failure */
  330. if ((result != 0 || !(respcmd & 0x8000))) {
  331. lbs_deb_host("CMD_RESP: error 0x%04x in command reply 0x%04x\n",
  332. result, respcmd);
  333. /*
  334. * Handling errors here
  335. */
  336. switch (respcmd) {
  337. case CMD_RET(CMD_GET_HW_SPEC):
  338. case CMD_RET(CMD_802_11_RESET):
  339. lbs_deb_host("CMD_RESP: reset failed\n");
  340. break;
  341. }
  342. lbs_complete_command(priv, priv->cur_cmd, result);
  343. spin_unlock_irqrestore(&priv->driver_lock, flags);
  344. ret = -1;
  345. goto done;
  346. }
  347. spin_unlock_irqrestore(&priv->driver_lock, flags);
  348. if (priv->cur_cmd && priv->cur_cmd->callback) {
  349. ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg,
  350. resp);
  351. } else
  352. ret = handle_cmd_response(priv, resp);
  353. spin_lock_irqsave(&priv->driver_lock, flags);
  354. if (priv->cur_cmd) {
  355. /* Clean up and Put current command back to cmdfreeq */
  356. lbs_complete_command(priv, priv->cur_cmd, result);
  357. }
  358. spin_unlock_irqrestore(&priv->driver_lock, flags);
  359. done:
  360. mutex_unlock(&priv->lock);
  361. lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
  362. return ret;
  363. }
  364. static int lbs_send_confirmwake(struct lbs_private *priv)
  365. {
  366. struct cmd_header cmd;
  367. int ret = 0;
  368. lbs_deb_enter(LBS_DEB_HOST);
  369. cmd.command = cpu_to_le16(CMD_802_11_WAKEUP_CONFIRM);
  370. cmd.size = cpu_to_le16(sizeof(cmd));
  371. cmd.seqnum = cpu_to_le16(++priv->seqnum);
  372. cmd.result = 0;
  373. lbs_deb_hex(LBS_DEB_HOST, "wake confirm", (u8 *) &cmd,
  374. sizeof(cmd));
  375. ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &cmd, sizeof(cmd));
  376. if (ret)
  377. lbs_pr_alert("SEND_WAKEC_CMD: Host to Card failed for Confirm Wake\n");
  378. lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
  379. return ret;
  380. }
  381. int lbs_process_event(struct lbs_private *priv, u32 event)
  382. {
  383. int ret = 0;
  384. lbs_deb_enter(LBS_DEB_CMD);
  385. switch (event) {
  386. case MACREG_INT_CODE_LINK_SENSED:
  387. lbs_deb_cmd("EVENT: link sensed\n");
  388. break;
  389. case MACREG_INT_CODE_DEAUTHENTICATED:
  390. lbs_deb_cmd("EVENT: deauthenticated\n");
  391. lbs_mac_event_disconnected(priv);
  392. break;
  393. case MACREG_INT_CODE_DISASSOCIATED:
  394. lbs_deb_cmd("EVENT: disassociated\n");
  395. lbs_mac_event_disconnected(priv);
  396. break;
  397. case MACREG_INT_CODE_LINK_LOST_NO_SCAN:
  398. lbs_deb_cmd("EVENT: link lost\n");
  399. lbs_mac_event_disconnected(priv);
  400. break;
  401. case MACREG_INT_CODE_PS_SLEEP:
  402. lbs_deb_cmd("EVENT: ps sleep\n");
  403. /* handle unexpected PS SLEEP event */
  404. if (priv->psstate == PS_STATE_FULL_POWER) {
  405. lbs_deb_cmd(
  406. "EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n");
  407. break;
  408. }
  409. priv->psstate = PS_STATE_PRE_SLEEP;
  410. lbs_ps_confirm_sleep(priv);
  411. break;
  412. case MACREG_INT_CODE_HOST_AWAKE:
  413. lbs_deb_cmd("EVENT: host awake\n");
  414. if (priv->reset_deep_sleep_wakeup)
  415. priv->reset_deep_sleep_wakeup(priv);
  416. priv->is_deep_sleep = 0;
  417. lbs_send_confirmwake(priv);
  418. break;
  419. case MACREG_INT_CODE_DEEP_SLEEP_AWAKE:
  420. if (priv->reset_deep_sleep_wakeup)
  421. priv->reset_deep_sleep_wakeup(priv);
  422. lbs_deb_cmd("EVENT: ds awake\n");
  423. priv->is_deep_sleep = 0;
  424. priv->wakeup_dev_required = 0;
  425. wake_up_interruptible(&priv->ds_awake_q);
  426. break;
  427. case MACREG_INT_CODE_PS_AWAKE:
  428. lbs_deb_cmd("EVENT: ps awake\n");
  429. /* handle unexpected PS AWAKE event */
  430. if (priv->psstate == PS_STATE_FULL_POWER) {
  431. lbs_deb_cmd(
  432. "EVENT: In FULL POWER mode - ignore PS AWAKE\n");
  433. break;
  434. }
  435. priv->psstate = PS_STATE_AWAKE;
  436. if (priv->needtowakeup) {
  437. /*
  438. * wait for the command processing to finish
  439. * before resuming sending
  440. * priv->needtowakeup will be set to FALSE
  441. * in lbs_ps_wakeup()
  442. */
  443. lbs_deb_cmd("waking up ...\n");
  444. lbs_ps_wakeup(priv, 0);
  445. }
  446. break;
  447. case MACREG_INT_CODE_MIC_ERR_UNICAST:
  448. lbs_deb_cmd("EVENT: UNICAST MIC ERROR\n");
  449. handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_UNICAST);
  450. break;
  451. case MACREG_INT_CODE_MIC_ERR_MULTICAST:
  452. lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n");
  453. handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST);
  454. break;
  455. case MACREG_INT_CODE_MIB_CHANGED:
  456. lbs_deb_cmd("EVENT: MIB CHANGED\n");
  457. break;
  458. case MACREG_INT_CODE_INIT_DONE:
  459. lbs_deb_cmd("EVENT: INIT DONE\n");
  460. break;
  461. case MACREG_INT_CODE_ADHOC_BCN_LOST:
  462. lbs_deb_cmd("EVENT: ADHOC beacon lost\n");
  463. break;
  464. case MACREG_INT_CODE_RSSI_LOW:
  465. lbs_pr_alert("EVENT: rssi low\n");
  466. break;
  467. case MACREG_INT_CODE_SNR_LOW:
  468. lbs_pr_alert("EVENT: snr low\n");
  469. break;
  470. case MACREG_INT_CODE_MAX_FAIL:
  471. lbs_pr_alert("EVENT: max fail\n");
  472. break;
  473. case MACREG_INT_CODE_RSSI_HIGH:
  474. lbs_pr_alert("EVENT: rssi high\n");
  475. break;
  476. case MACREG_INT_CODE_SNR_HIGH:
  477. lbs_pr_alert("EVENT: snr high\n");
  478. break;
  479. case MACREG_INT_CODE_MESH_AUTO_STARTED:
  480. /* Ignore spurious autostart events if autostart is disabled */
  481. if (!priv->mesh_autostart_enabled) {
  482. lbs_pr_info("EVENT: MESH_AUTO_STARTED (ignoring)\n");
  483. break;
  484. }
  485. lbs_pr_info("EVENT: MESH_AUTO_STARTED\n");
  486. priv->mesh_connect_status = LBS_CONNECTED;
  487. if (priv->mesh_open) {
  488. netif_carrier_on(priv->mesh_dev);
  489. if (!priv->tx_pending_len)
  490. netif_wake_queue(priv->mesh_dev);
  491. }
  492. priv->mode = IW_MODE_ADHOC;
  493. schedule_work(&priv->sync_channel);
  494. break;
  495. default:
  496. lbs_pr_alert("EVENT: unknown event id %d\n", event);
  497. break;
  498. }
  499. lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
  500. return ret;
  501. }