ps3-utils: Update package to include latest repository fixes
[openwrt.git] / package / libertas / src / cmdresp.c
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/if_arp.h>
7 #include <linux/netdevice.h>
8
9 #include <net/iw_handler.h>
10
11 #include "host.h"
12 #include "decl.h"
13 #include "defs.h"
14 #include "dev.h"
15 #include "assoc.h"
16 #include "wext.h"
17
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
30 if (priv->connect_status != LBS_CONNECTED)
31 return;
32
33 lbs_deb_enter(LBS_DEB_ASSOC);
34
35 memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN);
36 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
37
38 /*
39 * Cisco AP sends EAP failure and de-auth in less than 0.5 ms.
40 * It causes problem in the Supplicant
41 */
42
43 msleep_interruptible(1000);
44 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
45
46 /* report disconnect to upper layer */
47 netif_stop_queue(priv->dev);
48 netif_carrier_off(priv->dev);
49
50 /* Free Tx and Rx packets */
51 kfree_skb(priv->currenttxskb);
52 priv->currenttxskb = NULL;
53 priv->tx_pending_len = 0;
54
55 /* reset SNR/NF/RSSI values */
56 memset(priv->SNR, 0x00, sizeof(priv->SNR));
57 memset(priv->NF, 0x00, sizeof(priv->NF));
58 memset(priv->RSSI, 0x00, sizeof(priv->RSSI));
59 memset(priv->rawSNR, 0x00, sizeof(priv->rawSNR));
60 memset(priv->rawNF, 0x00, sizeof(priv->rawNF));
61 priv->nextSNRNF = 0;
62 priv->numSNRNF = 0;
63 priv->connect_status = LBS_DISCONNECTED;
64
65 /* Clear out associated SSID and BSSID since connection is
66 * no longer valid.
67 */
68 memset(&priv->curbssparams.bssid, 0, ETH_ALEN);
69 memset(&priv->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE);
70 priv->curbssparams.ssid_len = 0;
71
72 if (priv->psstate != PS_STATE_FULL_POWER) {
73 /* make firmware to exit PS mode */
74 lbs_deb_cmd("disconnected, so exit PS mode\n");
75 lbs_ps_wakeup(priv, 0);
76 }
77 lbs_deb_leave(LBS_DEB_ASSOC);
78 }
79
80 /**
81 * @brief This function handles MIC failure event.
82 *
83 * @param priv A pointer to struct lbs_private structure
84 * @para event the event id
85 * @return n/a
86 */
87 static void handle_mic_failureevent(struct lbs_private *priv, u32 event)
88 {
89 char buf[50];
90
91 lbs_deb_enter(LBS_DEB_CMD);
92 memset(buf, 0, sizeof(buf));
93
94 sprintf(buf, "%s", "MLME-MICHAELMICFAILURE.indication ");
95
96 if (event == MACREG_INT_CODE_MIC_ERR_UNICAST) {
97 strcat(buf, "unicast ");
98 } else {
99 strcat(buf, "multicast ");
100 }
101
102 lbs_send_iwevcustom_event(priv, buf);
103 lbs_deb_leave(LBS_DEB_CMD);
104 }
105
106 static int lbs_ret_reg_access(struct lbs_private *priv,
107 u16 type, struct cmd_ds_command *resp)
108 {
109 int ret = 0;
110
111 lbs_deb_enter(LBS_DEB_CMD);
112
113 switch (type) {
114 case CMD_RET(CMD_MAC_REG_ACCESS):
115 {
116 struct cmd_ds_mac_reg_access *reg = &resp->params.macreg;
117
118 priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
119 priv->offsetvalue.value = le32_to_cpu(reg->value);
120 break;
121 }
122
123 case CMD_RET(CMD_BBP_REG_ACCESS):
124 {
125 struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg;
126
127 priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
128 priv->offsetvalue.value = reg->value;
129 break;
130 }
131
132 case CMD_RET(CMD_RF_REG_ACCESS):
133 {
134 struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg;
135
136 priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
137 priv->offsetvalue.value = reg->value;
138 break;
139 }
140
141 default:
142 ret = -1;
143 }
144
145 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
146 return ret;
147 }
148
149 static int lbs_ret_802_11_snmp_mib(struct lbs_private *priv,
150 struct cmd_ds_command *resp)
151 {
152 struct cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
153 u16 oid = le16_to_cpu(smib->oid);
154 u16 querytype = le16_to_cpu(smib->querytype);
155
156 lbs_deb_enter(LBS_DEB_CMD);
157
158 lbs_deb_cmd("SNMP_RESP: oid 0x%x, querytype 0x%x\n", oid,
159 querytype);
160 lbs_deb_cmd("SNMP_RESP: Buf size %d\n", le16_to_cpu(smib->bufsize));
161
162 if (querytype == CMD_ACT_GET) {
163 switch (oid) {
164 case FRAGTHRESH_I:
165 priv->fragthsd =
166 le16_to_cpu(*((__le16 *)(smib->value)));
167 lbs_deb_cmd("SNMP_RESP: frag threshold %u\n",
168 priv->fragthsd);
169 break;
170 case RTSTHRESH_I:
171 priv->rtsthsd =
172 le16_to_cpu(*((__le16 *)(smib->value)));
173 lbs_deb_cmd("SNMP_RESP: rts threshold %u\n",
174 priv->rtsthsd);
175 break;
176 case SHORT_RETRYLIM_I:
177 priv->txretrycount =
178 le16_to_cpu(*((__le16 *)(smib->value)));
179 lbs_deb_cmd("SNMP_RESP: tx retry count %u\n",
180 priv->rtsthsd);
181 break;
182 default:
183 break;
184 }
185 }
186
187 lbs_deb_enter(LBS_DEB_CMD);
188 return 0;
189 }
190
191 static int lbs_ret_802_11_rf_tx_power(struct lbs_private *priv,
192 struct cmd_ds_command *resp)
193 {
194 struct cmd_ds_802_11_rf_tx_power *rtp = &resp->params.txp;
195
196 lbs_deb_enter(LBS_DEB_CMD);
197
198 priv->txpowerlevel = le16_to_cpu(rtp->currentlevel);
199
200 lbs_deb_cmd("TX power currently %d\n", priv->txpowerlevel);
201
202 lbs_deb_leave(LBS_DEB_CMD);
203 return 0;
204 }
205
206 static int lbs_ret_802_11_rate_adapt_rateset(struct lbs_private *priv,
207 struct cmd_ds_command *resp)
208 {
209 struct cmd_ds_802_11_rate_adapt_rateset *rates = &resp->params.rateset;
210
211 lbs_deb_enter(LBS_DEB_CMD);
212
213 if (rates->action == CMD_ACT_GET) {
214 priv->enablehwauto = le16_to_cpu(rates->enablehwauto);
215 priv->ratebitmap = le16_to_cpu(rates->bitmap);
216 }
217
218 lbs_deb_leave(LBS_DEB_CMD);
219 return 0;
220 }
221
222 static int lbs_ret_802_11_rssi(struct lbs_private *priv,
223 struct cmd_ds_command *resp)
224 {
225 struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp;
226
227 lbs_deb_enter(LBS_DEB_CMD);
228
229 /* store the non average value */
230 priv->SNR[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->SNR);
231 priv->NF[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->noisefloor);
232
233 priv->SNR[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgSNR);
234 priv->NF[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgnoisefloor);
235
236 priv->RSSI[TYPE_BEACON][TYPE_NOAVG] =
237 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
238 priv->NF[TYPE_BEACON][TYPE_NOAVG]);
239
240 priv->RSSI[TYPE_BEACON][TYPE_AVG] =
241 CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_AVG] / AVG_SCALE,
242 priv->NF[TYPE_BEACON][TYPE_AVG] / AVG_SCALE);
243
244 lbs_deb_cmd("RSSI: beacon %d, avg %d\n",
245 priv->RSSI[TYPE_BEACON][TYPE_NOAVG],
246 priv->RSSI[TYPE_BEACON][TYPE_AVG]);
247
248 lbs_deb_leave(LBS_DEB_CMD);
249 return 0;
250 }
251
252 static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv,
253 struct cmd_ds_command *resp)
254 {
255 struct cmd_ds_802_11_beacon_control *bcn_ctrl =
256 &resp->params.bcn_ctrl;
257
258 lbs_deb_enter(LBS_DEB_CMD);
259
260 if (bcn_ctrl->action == CMD_ACT_GET) {
261 priv->beacon_enable = (u8) le16_to_cpu(bcn_ctrl->beacon_enable);
262 priv->beacon_period = le16_to_cpu(bcn_ctrl->beacon_period);
263 }
264
265 lbs_deb_enter(LBS_DEB_CMD);
266 return 0;
267 }
268
269 static inline int handle_cmd_response(struct lbs_private *priv,
270 struct cmd_header *cmd_response)
271 {
272 struct cmd_ds_command *resp = (struct cmd_ds_command *) cmd_response;
273 int ret = 0;
274 unsigned long flags;
275 uint16_t respcmd = le16_to_cpu(resp->command);
276
277 lbs_deb_enter(LBS_DEB_HOST);
278
279 switch (respcmd) {
280 case CMD_RET(CMD_MAC_REG_ACCESS):
281 case CMD_RET(CMD_BBP_REG_ACCESS):
282 case CMD_RET(CMD_RF_REG_ACCESS):
283 ret = lbs_ret_reg_access(priv, respcmd, resp);
284 break;
285
286 case CMD_RET_802_11_ASSOCIATE:
287 case CMD_RET(CMD_802_11_ASSOCIATE):
288 case CMD_RET(CMD_802_11_REASSOCIATE):
289 ret = lbs_ret_80211_associate(priv, resp);
290 break;
291
292 case CMD_RET(CMD_802_11_DISASSOCIATE):
293 case CMD_RET(CMD_802_11_DEAUTHENTICATE):
294 ret = lbs_ret_80211_disassociate(priv);
295 break;
296
297 case CMD_RET(CMD_802_11_AD_HOC_START):
298 case CMD_RET(CMD_802_11_AD_HOC_JOIN):
299 ret = lbs_ret_80211_ad_hoc_start(priv, resp);
300 break;
301
302 case CMD_RET(CMD_802_11_SNMP_MIB):
303 ret = lbs_ret_802_11_snmp_mib(priv, resp);
304 break;
305
306 case CMD_RET(CMD_802_11_RF_TX_POWER):
307 ret = lbs_ret_802_11_rf_tx_power(priv, resp);
308 break;
309
310 case CMD_RET(CMD_802_11_SET_AFC):
311 case CMD_RET(CMD_802_11_GET_AFC):
312 spin_lock_irqsave(&priv->driver_lock, flags);
313 memmove((void *)priv->cur_cmd->callback_arg, &resp->params.afc,
314 sizeof(struct cmd_ds_802_11_afc));
315 spin_unlock_irqrestore(&priv->driver_lock, flags);
316
317 break;
318
319 case CMD_RET(CMD_MAC_MULTICAST_ADR):
320 case CMD_RET(CMD_802_11_RESET):
321 case CMD_RET(CMD_802_11_AUTHENTICATE):
322 case CMD_RET(CMD_802_11_BEACON_STOP):
323 break;
324
325 case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET):
326 ret = lbs_ret_802_11_rate_adapt_rateset(priv, resp);
327 break;
328
329 case CMD_RET(CMD_802_11_RSSI):
330 ret = lbs_ret_802_11_rssi(priv, resp);
331 break;
332
333 case CMD_RET(CMD_802_11_AD_HOC_STOP):
334 ret = lbs_ret_80211_ad_hoc_stop(priv);
335 break;
336
337 case CMD_RET(CMD_802_11D_DOMAIN_INFO):
338 ret = lbs_ret_802_11d_domain_info(resp);
339 break;
340
341 case CMD_RET(CMD_802_11_TPC_CFG):
342 spin_lock_irqsave(&priv->driver_lock, flags);
343 memmove((void *)priv->cur_cmd->callback_arg, &resp->params.tpccfg,
344 sizeof(struct cmd_ds_802_11_tpc_cfg));
345 spin_unlock_irqrestore(&priv->driver_lock, flags);
346 break;
347 case CMD_RET(CMD_802_11_LED_GPIO_CTRL):
348 spin_lock_irqsave(&priv->driver_lock, flags);
349 memmove((void *)priv->cur_cmd->callback_arg, &resp->params.ledgpio,
350 sizeof(struct cmd_ds_802_11_led_ctrl));
351 spin_unlock_irqrestore(&priv->driver_lock, flags);
352 break;
353
354 case CMD_RET(CMD_GET_TSF):
355 spin_lock_irqsave(&priv->driver_lock, flags);
356 memcpy((void *)priv->cur_cmd->callback_arg,
357 &resp->params.gettsf.tsfvalue, sizeof(u64));
358 spin_unlock_irqrestore(&priv->driver_lock, flags);
359 break;
360 case CMD_RET(CMD_BT_ACCESS):
361 spin_lock_irqsave(&priv->driver_lock, flags);
362 if (priv->cur_cmd->callback_arg)
363 memcpy((void *)priv->cur_cmd->callback_arg,
364 &resp->params.bt.addr1, 2 * ETH_ALEN);
365 spin_unlock_irqrestore(&priv->driver_lock, flags);
366 break;
367 case CMD_RET(CMD_FWT_ACCESS):
368 spin_lock_irqsave(&priv->driver_lock, flags);
369 if (priv->cur_cmd->callback_arg)
370 memcpy((void *)priv->cur_cmd->callback_arg, &resp->params.fwt,
371 sizeof(resp->params.fwt));
372 spin_unlock_irqrestore(&priv->driver_lock, flags);
373 break;
374 case CMD_RET(CMD_802_11_BEACON_CTRL):
375 ret = lbs_ret_802_11_bcn_ctrl(priv, resp);
376 break;
377
378 default:
379 lbs_deb_host("CMD_RESP: unknown cmd response 0x%04x\n",
380 le16_to_cpu(resp->command));
381 break;
382 }
383 lbs_deb_leave(LBS_DEB_HOST);
384 return ret;
385 }
386
387 int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
388 {
389 uint16_t respcmd, curcmd;
390 struct cmd_header *resp;
391 int ret = 0;
392 unsigned long flags;
393 uint16_t result;
394
395 lbs_deb_enter(LBS_DEB_HOST);
396
397 mutex_lock(&priv->lock);
398 spin_lock_irqsave(&priv->driver_lock, flags);
399
400 if (!priv->cur_cmd) {
401 lbs_deb_host("CMD_RESP: cur_cmd is NULL\n");
402 ret = -1;
403 spin_unlock_irqrestore(&priv->driver_lock, flags);
404 goto done;
405 }
406
407 resp = (void *)data;
408 curcmd = le16_to_cpu(priv->cur_cmd->cmdbuf->command);
409 respcmd = le16_to_cpu(resp->command);
410 result = le16_to_cpu(resp->result);
411
412 lbs_deb_cmd("CMD_RESP: response 0x%04x, seq %d, size %d\n",
413 respcmd, le16_to_cpu(resp->seqnum), len);
414 lbs_deb_hex(LBS_DEB_CMD, "CMD_RESP", (void *) resp, len);
415
416 if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) {
417 lbs_pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n",
418 le16_to_cpu(resp->seqnum), le16_to_cpu(priv->cur_cmd->cmdbuf->seqnum));
419 spin_unlock_irqrestore(&priv->driver_lock, flags);
420 ret = -1;
421 goto done;
422 }
423 if (respcmd != CMD_RET(curcmd) &&
424 respcmd != CMD_RET_802_11_ASSOCIATE && curcmd != CMD_802_11_ASSOCIATE) {
425 lbs_pr_info("Invalid CMD_RESP %x to command %x!\n", respcmd, curcmd);
426 spin_unlock_irqrestore(&priv->driver_lock, flags);
427 ret = -1;
428 goto done;
429 }
430
431 if (resp->result == cpu_to_le16(0x0004)) {
432 /* 0x0004 means -EAGAIN. Drop the response, let it time out
433 and be resubmitted */
434 lbs_pr_info("Firmware returns DEFER to command %x. Will let it time out...\n",
435 le16_to_cpu(resp->command));
436 spin_unlock_irqrestore(&priv->driver_lock, flags);
437 ret = -1;
438 goto done;
439 }
440
441 /* Now we got response from FW, cancel the command timer */
442 del_timer(&priv->command_timer);
443 priv->cmd_timed_out = 0;
444 if (priv->nr_retries) {
445 lbs_pr_info("Received result %x to command %x after %d retries\n",
446 result, curcmd, priv->nr_retries);
447 priv->nr_retries = 0;
448 }
449
450 /* Store the response code to cur_cmd_retcode. */
451 priv->cur_cmd_retcode = result;
452
453 if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) {
454 struct cmd_ds_802_11_ps_mode *psmode = (void *) &resp[1];
455 u16 action = le16_to_cpu(psmode->action);
456
457 lbs_deb_host(
458 "CMD_RESP: PS_MODE cmd reply result 0x%x, action 0x%x\n",
459 result, action);
460
461 if (result) {
462 lbs_deb_host("CMD_RESP: PS command failed with 0x%x\n",
463 result);
464 /*
465 * We should not re-try enter-ps command in
466 * ad-hoc mode. It takes place in
467 * lbs_execute_next_command().
468 */
469 if (priv->mode == IW_MODE_ADHOC &&
470 action == CMD_SUBCMD_ENTER_PS)
471 priv->psmode = LBS802_11POWERMODECAM;
472 } else if (action == CMD_SUBCMD_ENTER_PS) {
473 priv->needtowakeup = 0;
474 priv->psstate = PS_STATE_AWAKE;
475
476 lbs_deb_host("CMD_RESP: ENTER_PS command response\n");
477 if (priv->connect_status != LBS_CONNECTED) {
478 /*
479 * When Deauth Event received before Enter_PS command
480 * response, We need to wake up the firmware.
481 */
482 lbs_deb_host(
483 "disconnected, invoking lbs_ps_wakeup\n");
484
485 spin_unlock_irqrestore(&priv->driver_lock, flags);
486 mutex_unlock(&priv->lock);
487 lbs_ps_wakeup(priv, 0);
488 mutex_lock(&priv->lock);
489 spin_lock_irqsave(&priv->driver_lock, flags);
490 }
491 } else if (action == CMD_SUBCMD_EXIT_PS) {
492 priv->needtowakeup = 0;
493 priv->psstate = PS_STATE_FULL_POWER;
494 lbs_deb_host("CMD_RESP: EXIT_PS command response\n");
495 } else {
496 lbs_deb_host("CMD_RESP: PS action 0x%X\n", action);
497 }
498
499 lbs_complete_command(priv, priv->cur_cmd, result);
500 spin_unlock_irqrestore(&priv->driver_lock, flags);
501
502 ret = 0;
503 goto done;
504 }
505
506 /* If the command is not successful, cleanup and return failure */
507 if ((result != 0 || !(respcmd & 0x8000))) {
508 lbs_deb_host("CMD_RESP: error 0x%04x in command reply 0x%04x\n",
509 result, respcmd);
510 /*
511 * Handling errors here
512 */
513 switch (respcmd) {
514 case CMD_RET(CMD_GET_HW_SPEC):
515 case CMD_RET(CMD_802_11_RESET):
516 lbs_deb_host("CMD_RESP: reset failed\n");
517 break;
518
519 }
520 lbs_complete_command(priv, priv->cur_cmd, result);
521 spin_unlock_irqrestore(&priv->driver_lock, flags);
522
523 ret = -1;
524 goto done;
525 }
526
527 spin_unlock_irqrestore(&priv->driver_lock, flags);
528
529 if (priv->cur_cmd && priv->cur_cmd->callback) {
530 ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg,
531 resp);
532 } else
533 ret = handle_cmd_response(priv, resp);
534
535 spin_lock_irqsave(&priv->driver_lock, flags);
536
537 if (priv->cur_cmd) {
538 /* Clean up and Put current command back to cmdfreeq */
539 lbs_complete_command(priv, priv->cur_cmd, result);
540 }
541 spin_unlock_irqrestore(&priv->driver_lock, flags);
542
543 done:
544 mutex_unlock(&priv->lock);
545 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
546 return ret;
547 }
548
549 static int lbs_send_confirmwake(struct lbs_private *priv)
550 {
551 struct cmd_header cmd;
552 int ret = 0;
553
554 lbs_deb_enter(LBS_DEB_HOST);
555
556 cmd.command = cpu_to_le16(CMD_802_11_WAKEUP_CONFIRM);
557 cmd.size = cpu_to_le16(sizeof(cmd));
558 cmd.seqnum = cpu_to_le16(++priv->seqnum);
559 cmd.result = 0;
560
561 lbs_deb_hex(LBS_DEB_HOST, "wake confirm", (u8 *) &cmd,
562 sizeof(cmd));
563
564 ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &cmd, sizeof(cmd));
565 if (ret)
566 lbs_pr_alert("SEND_WAKEC_CMD: Host to Card failed for Confirm Wake\n");
567
568 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
569 return ret;
570 }
571
572 int lbs_process_event(struct lbs_private *priv, u32 event)
573 {
574 int ret = 0;
575
576 lbs_deb_enter(LBS_DEB_CMD);
577
578 switch (event) {
579 case MACREG_INT_CODE_LINK_SENSED:
580 lbs_deb_cmd("EVENT: link sensed\n");
581 break;
582
583 case MACREG_INT_CODE_DEAUTHENTICATED:
584 lbs_deb_cmd("EVENT: deauthenticated\n");
585 lbs_mac_event_disconnected(priv);
586 break;
587
588 case MACREG_INT_CODE_DISASSOCIATED:
589 lbs_deb_cmd("EVENT: disassociated\n");
590 lbs_mac_event_disconnected(priv);
591 break;
592
593 case MACREG_INT_CODE_LINK_LOST_NO_SCAN:
594 lbs_deb_cmd("EVENT: link lost\n");
595 lbs_mac_event_disconnected(priv);
596 break;
597
598 case MACREG_INT_CODE_PS_SLEEP:
599 lbs_deb_cmd("EVENT: ps sleep\n");
600
601 /* handle unexpected PS SLEEP event */
602 if (priv->psstate == PS_STATE_FULL_POWER) {
603 lbs_deb_cmd(
604 "EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n");
605 break;
606 }
607 priv->psstate = PS_STATE_PRE_SLEEP;
608
609 lbs_ps_confirm_sleep(priv);
610
611 break;
612
613 case MACREG_INT_CODE_HOST_AWAKE:
614 lbs_deb_cmd("EVENT: host awake\n");
615 lbs_send_confirmwake(priv);
616 break;
617
618 case MACREG_INT_CODE_PS_AWAKE:
619 lbs_deb_cmd("EVENT: ps awake\n");
620 /* handle unexpected PS AWAKE event */
621 if (priv->psstate == PS_STATE_FULL_POWER) {
622 lbs_deb_cmd(
623 "EVENT: In FULL POWER mode - ignore PS AWAKE\n");
624 break;
625 }
626
627 priv->psstate = PS_STATE_AWAKE;
628
629 if (priv->needtowakeup) {
630 /*
631 * wait for the command processing to finish
632 * before resuming sending
633 * priv->needtowakeup will be set to FALSE
634 * in lbs_ps_wakeup()
635 */
636 lbs_deb_cmd("waking up ...\n");
637 lbs_ps_wakeup(priv, 0);
638 }
639 break;
640
641 case MACREG_INT_CODE_MIC_ERR_UNICAST:
642 lbs_deb_cmd("EVENT: UNICAST MIC ERROR\n");
643 handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_UNICAST);
644 break;
645
646 case MACREG_INT_CODE_MIC_ERR_MULTICAST:
647 lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n");
648 handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST);
649 break;
650
651 case MACREG_INT_CODE_MIB_CHANGED:
652 lbs_deb_cmd("EVENT: MIB CHANGED\n");
653 break;
654 case MACREG_INT_CODE_INIT_DONE:
655 lbs_deb_cmd("EVENT: INIT DONE\n");
656 break;
657 case MACREG_INT_CODE_ADHOC_BCN_LOST:
658 lbs_deb_cmd("EVENT: ADHOC beacon lost\n");
659 break;
660 case MACREG_INT_CODE_RSSI_LOW:
661 lbs_pr_alert("EVENT: rssi low\n");
662 break;
663 case MACREG_INT_CODE_SNR_LOW:
664 lbs_pr_alert("EVENT: snr low\n");
665 break;
666 case MACREG_INT_CODE_MAX_FAIL:
667 lbs_pr_alert("EVENT: max fail\n");
668 break;
669 case MACREG_INT_CODE_RSSI_HIGH:
670 lbs_pr_alert("EVENT: rssi high\n");
671 break;
672 case MACREG_INT_CODE_SNR_HIGH:
673 lbs_pr_alert("EVENT: snr high\n");
674 break;
675
676 case MACREG_INT_CODE_MESH_AUTO_STARTED:
677 /* Ignore spurious autostart events if autostart is disabled */
678 if (!priv->mesh_autostart_enabled) {
679 lbs_pr_info("EVENT: MESH_AUTO_STARTED (ignoring)\n");
680 break;
681 }
682 lbs_pr_info("EVENT: MESH_AUTO_STARTED\n");
683 priv->mesh_connect_status = LBS_CONNECTED;
684 if (priv->mesh_open) {
685 netif_carrier_on(priv->mesh_dev);
686 if (!priv->tx_pending_len)
687 netif_wake_queue(priv->mesh_dev);
688 }
689 priv->mode = IW_MODE_ADHOC;
690 schedule_work(&priv->sync_channel);
691 break;
692
693 default:
694 lbs_pr_alert("EVENT: unknown event id %d\n", event);
695 break;
696 }
697
698 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
699 return ret;
700 }
This page took 0.100424 seconds and 5 git commands to generate.