1 /*
2 * Marvell Wireless LAN device driver: station event handling
3 *
4 * Copyright (C) 2011-2014, Marvell International Ltd.
5 *
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13 *
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
18 */
19
20 #include "decl.h"
21 #include "ioctl.h"
22 #include "util.h"
23 #include "fw.h"
24 #include "main.h"
25 #include "wmm.h"
26 #include "11n.h"
27
28 /*
29 * This function resets the connection state.
30 *
31 * The function is invoked after receiving a disconnect event from firmware,
32 * and performs the following actions -
33 * - Set media status to disconnected
34 * - Clean up Tx and Rx packets
35 * - Resets SNR/NF/RSSI value in driver
36 * - Resets security configurations in driver
37 * - Enables auto data rate
38 * - Saves the previous SSID and BSSID so that they can
39 * be used for re-association, if required
40 * - Erases current SSID and BSSID information
41 * - Sends a disconnect event to upper layers/applications.
42 */
43 void
mwifiex_reset_connect_state(struct mwifiex_private * priv,u16 reason_code)44 mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code)
45 {
46 struct mwifiex_adapter *adapter = priv->adapter;
47
48 if (!priv->media_connected)
49 return;
50
51 mwifiex_dbg(adapter, INFO,
52 "info: handles disconnect event\n");
53
54 priv->media_connected = false;
55
56 priv->scan_block = false;
57 priv->port_open = false;
58
59 if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
60 ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info)) {
61 mwifiex_disable_all_tdls_links(priv);
62
63 if (priv->adapter->auto_tdls)
64 mwifiex_clean_auto_tdls(priv);
65 }
66
67 /* Free Tx and Rx packets, report disconnect to upper layer */
68 mwifiex_clean_txrx(priv);
69
70 /* Reset SNR/NF/RSSI values */
71 priv->data_rssi_last = 0;
72 priv->data_nf_last = 0;
73 priv->data_rssi_avg = 0;
74 priv->data_nf_avg = 0;
75 priv->bcn_rssi_last = 0;
76 priv->bcn_nf_last = 0;
77 priv->bcn_rssi_avg = 0;
78 priv->bcn_nf_avg = 0;
79 priv->rxpd_rate = 0;
80 priv->rxpd_htinfo = 0;
81 priv->sec_info.wpa_enabled = false;
82 priv->sec_info.wpa2_enabled = false;
83 priv->wpa_ie_len = 0;
84
85 priv->sec_info.wapi_enabled = false;
86 priv->wapi_ie_len = 0;
87 priv->sec_info.wapi_key_on = false;
88
89 priv->sec_info.encryption_mode = 0;
90
91 /* Enable auto data rate */
92 priv->is_data_rate_auto = true;
93 priv->data_rate = 0;
94
95 if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA ||
96 GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) && priv->hist_data)
97 mwifiex_hist_data_reset(priv);
98
99 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
100 priv->adhoc_state = ADHOC_IDLE;
101 priv->adhoc_is_link_sensed = false;
102 }
103
104 /*
105 * Memorize the previous SSID and BSSID so
106 * it could be used for re-assoc
107 */
108
109 mwifiex_dbg(adapter, INFO,
110 "info: previous SSID=%s, SSID len=%u\n",
111 priv->prev_ssid.ssid, priv->prev_ssid.ssid_len);
112
113 mwifiex_dbg(adapter, INFO,
114 "info: current SSID=%s, SSID len=%u\n",
115 priv->curr_bss_params.bss_descriptor.ssid.ssid,
116 priv->curr_bss_params.bss_descriptor.ssid.ssid_len);
117
118 memcpy(&priv->prev_ssid,
119 &priv->curr_bss_params.bss_descriptor.ssid,
120 sizeof(struct cfg80211_ssid));
121
122 memcpy(priv->prev_bssid,
123 priv->curr_bss_params.bss_descriptor.mac_address, ETH_ALEN);
124
125 /* Need to erase the current SSID and BSSID info */
126 memset(&priv->curr_bss_params, 0x00, sizeof(priv->curr_bss_params));
127
128 adapter->tx_lock_flag = false;
129 adapter->pps_uapsd_mode = false;
130
131 if (adapter->is_cmd_timedout && adapter->curr_cmd)
132 return;
133 priv->media_connected = false;
134 mwifiex_dbg(adapter, MSG,
135 "info: successfully disconnected from %pM: reason code %d\n",
136 priv->cfg_bssid, reason_code);
137 if (priv->bss_mode == NL80211_IFTYPE_STATION ||
138 priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) {
139 cfg80211_disconnected(priv->netdev, reason_code, NULL, 0,
140 false, GFP_KERNEL);
141 }
142 eth_zero_addr(priv->cfg_bssid);
143
144 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
145 if (netif_carrier_ok(priv->netdev))
146 netif_carrier_off(priv->netdev);
147 }
148
mwifiex_parse_tdls_event(struct mwifiex_private * priv,struct sk_buff * event_skb)149 static int mwifiex_parse_tdls_event(struct mwifiex_private *priv,
150 struct sk_buff *event_skb)
151 {
152 int ret = 0;
153 struct mwifiex_adapter *adapter = priv->adapter;
154 struct mwifiex_sta_node *sta_ptr;
155 struct mwifiex_tdls_generic_event *tdls_evt =
156 (void *)event_skb->data + sizeof(adapter->event_cause);
157 u8 *mac = tdls_evt->peer_mac;
158
159 /* reserved 2 bytes are not mandatory in tdls event */
160 if (event_skb->len < (sizeof(struct mwifiex_tdls_generic_event) -
161 sizeof(u16) - sizeof(adapter->event_cause))) {
162 mwifiex_dbg(adapter, ERROR, "Invalid event length!\n");
163 return -1;
164 }
165
166 sta_ptr = mwifiex_get_sta_entry(priv, tdls_evt->peer_mac);
167 if (!sta_ptr) {
168 mwifiex_dbg(adapter, ERROR, "cannot get sta entry!\n");
169 return -1;
170 }
171
172 switch (le16_to_cpu(tdls_evt->type)) {
173 case TDLS_EVENT_LINK_TEAR_DOWN:
174 cfg80211_tdls_oper_request(priv->netdev,
175 tdls_evt->peer_mac,
176 NL80211_TDLS_TEARDOWN,
177 le16_to_cpu(tdls_evt->u.reason_code),
178 GFP_KERNEL);
179 break;
180 case TDLS_EVENT_CHAN_SWITCH_RESULT:
181 mwifiex_dbg(adapter, EVENT, "tdls channel switch result :\n");
182 mwifiex_dbg(adapter, EVENT,
183 "status=0x%x, reason=0x%x cur_chan=%d\n",
184 tdls_evt->u.switch_result.status,
185 tdls_evt->u.switch_result.reason,
186 tdls_evt->u.switch_result.cur_chan);
187
188 /* tdls channel switch failed */
189 if (tdls_evt->u.switch_result.status != 0) {
190 switch (tdls_evt->u.switch_result.cur_chan) {
191 case TDLS_BASE_CHANNEL:
192 sta_ptr->tdls_status = TDLS_IN_BASE_CHAN;
193 break;
194 case TDLS_OFF_CHANNEL:
195 sta_ptr->tdls_status = TDLS_IN_OFF_CHAN;
196 break;
197 default:
198 break;
199 }
200 return ret;
201 }
202
203 /* tdls channel switch success */
204 switch (tdls_evt->u.switch_result.cur_chan) {
205 case TDLS_BASE_CHANNEL:
206 if (sta_ptr->tdls_status == TDLS_IN_BASE_CHAN)
207 break;
208 mwifiex_update_ralist_tx_pause_in_tdls_cs(priv, mac,
209 false);
210 sta_ptr->tdls_status = TDLS_IN_BASE_CHAN;
211 break;
212 case TDLS_OFF_CHANNEL:
213 if (sta_ptr->tdls_status == TDLS_IN_OFF_CHAN)
214 break;
215 mwifiex_update_ralist_tx_pause_in_tdls_cs(priv, mac,
216 true);
217 sta_ptr->tdls_status = TDLS_IN_OFF_CHAN;
218 break;
219 default:
220 break;
221 }
222
223 break;
224 case TDLS_EVENT_START_CHAN_SWITCH:
225 mwifiex_dbg(adapter, EVENT, "tdls start channel switch...\n");
226 sta_ptr->tdls_status = TDLS_CHAN_SWITCHING;
227 break;
228 case TDLS_EVENT_CHAN_SWITCH_STOPPED:
229 mwifiex_dbg(adapter, EVENT,
230 "tdls chan switch stopped, reason=%d\n",
231 tdls_evt->u.cs_stop_reason);
232 break;
233 default:
234 break;
235 }
236
237 return ret;
238 }
239
mwifiex_process_uap_tx_pause(struct mwifiex_private * priv,struct mwifiex_ie_types_header * tlv)240 static void mwifiex_process_uap_tx_pause(struct mwifiex_private *priv,
241 struct mwifiex_ie_types_header *tlv)
242 {
243 struct mwifiex_tx_pause_tlv *tp;
244 struct mwifiex_sta_node *sta_ptr;
245 unsigned long flags;
246
247 tp = (void *)tlv;
248 mwifiex_dbg(priv->adapter, EVENT,
249 "uap tx_pause: %pM pause=%d, pkts=%d\n",
250 tp->peermac, tp->tx_pause,
251 tp->pkt_cnt);
252
253 if (ether_addr_equal(tp->peermac, priv->netdev->dev_addr)) {
254 if (tp->tx_pause)
255 priv->port_open = false;
256 else
257 priv->port_open = true;
258 } else if (is_multicast_ether_addr(tp->peermac)) {
259 mwifiex_update_ralist_tx_pause(priv, tp->peermac, tp->tx_pause);
260 } else {
261 spin_lock_irqsave(&priv->sta_list_spinlock, flags);
262 sta_ptr = mwifiex_get_sta_entry(priv, tp->peermac);
263 spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
264
265 if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) {
266 sta_ptr->tx_pause = tp->tx_pause;
267 mwifiex_update_ralist_tx_pause(priv, tp->peermac,
268 tp->tx_pause);
269 }
270 }
271 }
272
mwifiex_process_sta_tx_pause(struct mwifiex_private * priv,struct mwifiex_ie_types_header * tlv)273 static void mwifiex_process_sta_tx_pause(struct mwifiex_private *priv,
274 struct mwifiex_ie_types_header *tlv)
275 {
276 struct mwifiex_tx_pause_tlv *tp;
277 struct mwifiex_sta_node *sta_ptr;
278 int status;
279 unsigned long flags;
280
281 tp = (void *)tlv;
282 mwifiex_dbg(priv->adapter, EVENT,
283 "sta tx_pause: %pM pause=%d, pkts=%d\n",
284 tp->peermac, tp->tx_pause,
285 tp->pkt_cnt);
286
287 if (ether_addr_equal(tp->peermac, priv->cfg_bssid)) {
288 if (tp->tx_pause)
289 priv->port_open = false;
290 else
291 priv->port_open = true;
292 } else {
293 if (!ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info))
294 return;
295
296 status = mwifiex_get_tdls_link_status(priv, tp->peermac);
297 if (mwifiex_is_tdls_link_setup(status)) {
298 spin_lock_irqsave(&priv->sta_list_spinlock, flags);
299 sta_ptr = mwifiex_get_sta_entry(priv, tp->peermac);
300 spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
301
302 if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) {
303 sta_ptr->tx_pause = tp->tx_pause;
304 mwifiex_update_ralist_tx_pause(priv,
305 tp->peermac,
306 tp->tx_pause);
307 }
308 }
309 }
310 }
311
mwifiex_process_multi_chan_event(struct mwifiex_private * priv,struct sk_buff * event_skb)312 void mwifiex_process_multi_chan_event(struct mwifiex_private *priv,
313 struct sk_buff *event_skb)
314 {
315 struct mwifiex_ie_types_multi_chan_info *chan_info;
316 struct mwifiex_ie_types_mc_group_info *grp_info;
317 struct mwifiex_adapter *adapter = priv->adapter;
318 struct mwifiex_ie_types_header *tlv;
319 u16 tlv_buf_left, tlv_type, tlv_len;
320 int intf_num, bss_type, bss_num, i;
321 struct mwifiex_private *intf_priv;
322
323 tlv_buf_left = event_skb->len - sizeof(u32);
324 chan_info = (void *)event_skb->data + sizeof(u32);
325
326 if (le16_to_cpu(chan_info->header.type) != TLV_TYPE_MULTI_CHAN_INFO ||
327 tlv_buf_left < sizeof(struct mwifiex_ie_types_multi_chan_info)) {
328 mwifiex_dbg(adapter, ERROR,
329 "unknown TLV in chan_info event\n");
330 return;
331 }
332
333 adapter->usb_mc_status = le16_to_cpu(chan_info->status);
334 mwifiex_dbg(adapter, EVENT, "multi chan operation %s\n",
335 adapter->usb_mc_status ? "started" : "over");
336
337 tlv_buf_left -= sizeof(struct mwifiex_ie_types_multi_chan_info);
338 tlv = (struct mwifiex_ie_types_header *)chan_info->tlv_buffer;
339
340 while (tlv_buf_left >= (int)sizeof(struct mwifiex_ie_types_header)) {
341 tlv_type = le16_to_cpu(tlv->type);
342 tlv_len = le16_to_cpu(tlv->len);
343 if ((sizeof(struct mwifiex_ie_types_header) + tlv_len) >
344 tlv_buf_left) {
345 mwifiex_dbg(adapter, ERROR, "wrong tlv: tlvLen=%d,\t"
346 "tlvBufLeft=%d\n", tlv_len, tlv_buf_left);
347 break;
348 }
349 if (tlv_type != TLV_TYPE_MC_GROUP_INFO) {
350 mwifiex_dbg(adapter, ERROR, "wrong tlv type: 0x%x\n",
351 tlv_type);
352 break;
353 }
354
355 grp_info = (struct mwifiex_ie_types_mc_group_info *)tlv;
356 intf_num = grp_info->intf_num;
357 for (i = 0; i < intf_num; i++) {
358 bss_type = grp_info->bss_type_numlist[i] >> 4;
359 bss_num = grp_info->bss_type_numlist[i] & BSS_NUM_MASK;
360 intf_priv = mwifiex_get_priv_by_id(adapter, bss_num,
361 bss_type);
362 if (!intf_priv) {
363 mwifiex_dbg(adapter, ERROR,
364 "Invalid bss_type bss_num\t"
365 "in multi channel event\n");
366 continue;
367 }
368 if (adapter->iface_type == MWIFIEX_USB) {
369 u8 ep;
370
371 ep = grp_info->hid_num.usb_ep_num;
372 if (ep == MWIFIEX_USB_EP_DATA ||
373 ep == MWIFIEX_USB_EP_DATA_CH2)
374 intf_priv->usb_port = ep;
375 }
376 }
377
378 tlv_buf_left -= sizeof(struct mwifiex_ie_types_header) +
379 tlv_len;
380 tlv = (void *)((u8 *)tlv + tlv_len +
381 sizeof(struct mwifiex_ie_types_header));
382 }
383
384 if (adapter->iface_type == MWIFIEX_USB) {
385 adapter->tx_lock_flag = true;
386 adapter->usb_mc_setup = true;
387 mwifiex_multi_chan_resync(adapter);
388 }
389 }
390
mwifiex_process_tx_pause_event(struct mwifiex_private * priv,struct sk_buff * event_skb)391 void mwifiex_process_tx_pause_event(struct mwifiex_private *priv,
392 struct sk_buff *event_skb)
393 {
394 struct mwifiex_ie_types_header *tlv;
395 u16 tlv_type, tlv_len;
396 int tlv_buf_left;
397
398 if (!priv->media_connected) {
399 mwifiex_dbg(priv->adapter, ERROR,
400 "tx_pause event while disconnected; bss_role=%d\n",
401 priv->bss_role);
402 return;
403 }
404
405 tlv_buf_left = event_skb->len - sizeof(u32);
406 tlv = (void *)event_skb->data + sizeof(u32);
407
408 while (tlv_buf_left >= (int)sizeof(struct mwifiex_ie_types_header)) {
409 tlv_type = le16_to_cpu(tlv->type);
410 tlv_len = le16_to_cpu(tlv->len);
411 if ((sizeof(struct mwifiex_ie_types_header) + tlv_len) >
412 tlv_buf_left) {
413 mwifiex_dbg(priv->adapter, ERROR,
414 "wrong tlv: tlvLen=%d, tlvBufLeft=%d\n",
415 tlv_len, tlv_buf_left);
416 break;
417 }
418 if (tlv_type == TLV_TYPE_TX_PAUSE) {
419 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA)
420 mwifiex_process_sta_tx_pause(priv, tlv);
421 else
422 mwifiex_process_uap_tx_pause(priv, tlv);
423 }
424
425 tlv_buf_left -= sizeof(struct mwifiex_ie_types_header) +
426 tlv_len;
427 tlv = (void *)((u8 *)tlv + tlv_len +
428 sizeof(struct mwifiex_ie_types_header));
429 }
430
431 }
432
433 /*
434 * This function handles coex events generated by firmware
435 */
mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private * priv,struct sk_buff * event_skb)436 void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv,
437 struct sk_buff *event_skb)
438 {
439 struct mwifiex_adapter *adapter = priv->adapter;
440 struct mwifiex_ie_types_header *tlv;
441 struct mwifiex_ie_types_btcoex_aggr_win_size *winsizetlv;
442 struct mwifiex_ie_types_btcoex_scan_time *scantlv;
443 s32 len = event_skb->len - sizeof(u32);
444 u8 *cur_ptr = event_skb->data + sizeof(u32);
445 u16 tlv_type, tlv_len;
446
447 while (len >= sizeof(struct mwifiex_ie_types_header)) {
448 tlv = (struct mwifiex_ie_types_header *)cur_ptr;
449 tlv_len = le16_to_cpu(tlv->len);
450 tlv_type = le16_to_cpu(tlv->type);
451
452 if ((tlv_len + sizeof(struct mwifiex_ie_types_header)) > len)
453 break;
454 switch (tlv_type) {
455 case TLV_BTCOEX_WL_AGGR_WINSIZE:
456 winsizetlv =
457 (struct mwifiex_ie_types_btcoex_aggr_win_size *)tlv;
458 adapter->coex_win_size = winsizetlv->coex_win_size;
459 adapter->coex_tx_win_size =
460 winsizetlv->tx_win_size;
461 adapter->coex_rx_win_size =
462 winsizetlv->rx_win_size;
463 mwifiex_coex_ampdu_rxwinsize(adapter);
464 mwifiex_update_ampdu_txwinsize(adapter);
465 break;
466
467 case TLV_BTCOEX_WL_SCANTIME:
468 scantlv =
469 (struct mwifiex_ie_types_btcoex_scan_time *)tlv;
470 adapter->coex_scan = scantlv->coex_scan;
471 adapter->coex_min_scan_time = scantlv->min_scan_time;
472 adapter->coex_max_scan_time = scantlv->max_scan_time;
473 break;
474
475 default:
476 break;
477 }
478
479 len -= tlv_len + sizeof(struct mwifiex_ie_types_header);
480 cur_ptr += tlv_len +
481 sizeof(struct mwifiex_ie_types_header);
482 }
483
484 dev_dbg(adapter->dev, "coex_scan=%d min_scan=%d coex_win=%d, tx_win=%d rx_win=%d\n",
485 adapter->coex_scan, adapter->coex_min_scan_time,
486 adapter->coex_win_size, adapter->coex_tx_win_size,
487 adapter->coex_rx_win_size);
488 }
489
490 /*
491 * This function handles events generated by firmware.
492 *
493 * This is a generic function and handles all events.
494 *
495 * Event specific routines are called by this function based
496 * upon the generated event cause.
497 *
498 * For the following events, the function just forwards them to upper
499 * layers, optionally recording the change -
500 * - EVENT_LINK_SENSED
501 * - EVENT_MIC_ERR_UNICAST
502 * - EVENT_MIC_ERR_MULTICAST
503 * - EVENT_PORT_RELEASE
504 * - EVENT_RSSI_LOW
505 * - EVENT_SNR_LOW
506 * - EVENT_MAX_FAIL
507 * - EVENT_RSSI_HIGH
508 * - EVENT_SNR_HIGH
509 * - EVENT_DATA_RSSI_LOW
510 * - EVENT_DATA_SNR_LOW
511 * - EVENT_DATA_RSSI_HIGH
512 * - EVENT_DATA_SNR_HIGH
513 * - EVENT_LINK_QUALITY
514 * - EVENT_PRE_BEACON_LOST
515 * - EVENT_IBSS_COALESCED
516 * - EVENT_WEP_ICV_ERR
517 * - EVENT_BW_CHANGE
518 * - EVENT_HOSTWAKE_STAIE
519 *
520 * For the following events, no action is taken -
521 * - EVENT_MIB_CHANGED
522 * - EVENT_INIT_DONE
523 * - EVENT_DUMMY_HOST_WAKEUP_SIGNAL
524 *
525 * Rest of the supported events requires driver handling -
526 * - EVENT_DEAUTHENTICATED
527 * - EVENT_DISASSOCIATED
528 * - EVENT_LINK_LOST
529 * - EVENT_PS_SLEEP
530 * - EVENT_PS_AWAKE
531 * - EVENT_DEEP_SLEEP_AWAKE
532 * - EVENT_HS_ACT_REQ
533 * - EVENT_ADHOC_BCN_LOST
534 * - EVENT_BG_SCAN_REPORT
535 * - EVENT_WMM_STATUS_CHANGE
536 * - EVENT_ADDBA
537 * - EVENT_DELBA
538 * - EVENT_BA_STREAM_TIEMOUT
539 * - EVENT_AMSDU_AGGR_CTRL
540 */
mwifiex_process_sta_event(struct mwifiex_private * priv)541 int mwifiex_process_sta_event(struct mwifiex_private *priv)
542 {
543 struct mwifiex_adapter *adapter = priv->adapter;
544 int ret = 0;
545 u32 eventcause = adapter->event_cause;
546 u16 ctrl, reason_code;
547
548 switch (eventcause) {
549 case EVENT_DUMMY_HOST_WAKEUP_SIGNAL:
550 mwifiex_dbg(adapter, ERROR,
551 "invalid EVENT: DUMMY_HOST_WAKEUP_SIGNAL, ignore it\n");
552 break;
553 case EVENT_LINK_SENSED:
554 mwifiex_dbg(adapter, EVENT, "event: LINK_SENSED\n");
555 if (!netif_carrier_ok(priv->netdev))
556 netif_carrier_on(priv->netdev);
557 mwifiex_wake_up_net_dev_queue(priv->netdev, adapter);
558 break;
559
560 case EVENT_DEAUTHENTICATED:
561 mwifiex_dbg(adapter, EVENT, "event: Deauthenticated\n");
562 if (priv->wps.session_enable) {
563 mwifiex_dbg(adapter, INFO,
564 "info: receive deauth event in wps session\n");
565 break;
566 }
567 adapter->dbg.num_event_deauth++;
568 if (priv->media_connected) {
569 reason_code =
570 le16_to_cpu(*(__le16 *)adapter->event_body);
571 mwifiex_reset_connect_state(priv, reason_code);
572 }
573 break;
574
575 case EVENT_DISASSOCIATED:
576 mwifiex_dbg(adapter, EVENT, "event: Disassociated\n");
577 if (priv->wps.session_enable) {
578 mwifiex_dbg(adapter, INFO,
579 "info: receive disassoc event in wps session\n");
580 break;
581 }
582 adapter->dbg.num_event_disassoc++;
583 if (priv->media_connected) {
584 reason_code =
585 le16_to_cpu(*(__le16 *)adapter->event_body);
586 mwifiex_reset_connect_state(priv, reason_code);
587 }
588 break;
589
590 case EVENT_LINK_LOST:
591 mwifiex_dbg(adapter, EVENT, "event: Link lost\n");
592 adapter->dbg.num_event_link_lost++;
593 if (priv->media_connected) {
594 reason_code =
595 le16_to_cpu(*(__le16 *)adapter->event_body);
596 mwifiex_reset_connect_state(priv, reason_code);
597 }
598 break;
599
600 case EVENT_PS_SLEEP:
601 mwifiex_dbg(adapter, EVENT, "info: EVENT: SLEEP\n");
602
603 adapter->ps_state = PS_STATE_PRE_SLEEP;
604
605 mwifiex_check_ps_cond(adapter);
606 break;
607
608 case EVENT_PS_AWAKE:
609 mwifiex_dbg(adapter, EVENT, "info: EVENT: AWAKE\n");
610 if (!adapter->pps_uapsd_mode &&
611 (priv->port_open ||
612 (priv->bss_mode == NL80211_IFTYPE_ADHOC)) &&
613 priv->media_connected && adapter->sleep_period.period) {
614 adapter->pps_uapsd_mode = true;
615 mwifiex_dbg(adapter, EVENT,
616 "event: PPS/UAPSD mode activated\n");
617 }
618 adapter->tx_lock_flag = false;
619 if (adapter->pps_uapsd_mode && adapter->gen_null_pkt) {
620 if (mwifiex_check_last_packet_indication(priv)) {
621 if (adapter->data_sent ||
622 (adapter->if_ops.is_port_ready &&
623 !adapter->if_ops.is_port_ready(priv))) {
624 adapter->ps_state = PS_STATE_AWAKE;
625 adapter->pm_wakeup_card_req = false;
626 adapter->pm_wakeup_fw_try = false;
627 del_timer(&adapter->wakeup_timer);
628 break;
629 }
630 if (!mwifiex_send_null_packet
631 (priv,
632 MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET |
633 MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET))
634 adapter->ps_state =
635 PS_STATE_SLEEP;
636 return 0;
637 }
638 }
639 adapter->ps_state = PS_STATE_AWAKE;
640 adapter->pm_wakeup_card_req = false;
641 adapter->pm_wakeup_fw_try = false;
642 del_timer(&adapter->wakeup_timer);
643
644 break;
645
646 case EVENT_DEEP_SLEEP_AWAKE:
647 adapter->if_ops.wakeup_complete(adapter);
648 mwifiex_dbg(adapter, EVENT, "event: DS_AWAKE\n");
649 if (adapter->is_deep_sleep)
650 adapter->is_deep_sleep = false;
651 break;
652
653 case EVENT_HS_ACT_REQ:
654 mwifiex_dbg(adapter, EVENT, "event: HS_ACT_REQ\n");
655 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_HS_CFG_ENH,
656 0, 0, NULL, false);
657 break;
658
659 case EVENT_MIC_ERR_UNICAST:
660 mwifiex_dbg(adapter, EVENT, "event: UNICAST MIC ERROR\n");
661 cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid,
662 NL80211_KEYTYPE_PAIRWISE,
663 -1, NULL, GFP_KERNEL);
664 break;
665
666 case EVENT_MIC_ERR_MULTICAST:
667 mwifiex_dbg(adapter, EVENT, "event: MULTICAST MIC ERROR\n");
668 cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid,
669 NL80211_KEYTYPE_GROUP,
670 -1, NULL, GFP_KERNEL);
671 break;
672 case EVENT_MIB_CHANGED:
673 case EVENT_INIT_DONE:
674 break;
675
676 case EVENT_ADHOC_BCN_LOST:
677 mwifiex_dbg(adapter, EVENT, "event: ADHOC_BCN_LOST\n");
678 priv->adhoc_is_link_sensed = false;
679 mwifiex_clean_txrx(priv);
680 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
681 if (netif_carrier_ok(priv->netdev))
682 netif_carrier_off(priv->netdev);
683 break;
684
685 case EVENT_BG_SCAN_REPORT:
686 mwifiex_dbg(adapter, EVENT, "event: BGS_REPORT\n");
687 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_BG_SCAN_QUERY,
688 HostCmd_ACT_GEN_GET, 0, NULL, false);
689 break;
690
691 case EVENT_PORT_RELEASE:
692 mwifiex_dbg(adapter, EVENT, "event: PORT RELEASE\n");
693 priv->port_open = true;
694 break;
695
696 case EVENT_EXT_SCAN_REPORT:
697 mwifiex_dbg(adapter, EVENT, "event: EXT_SCAN Report\n");
698 if (adapter->ext_scan)
699 ret = mwifiex_handle_event_ext_scan_report(priv,
700 adapter->event_skb->data);
701
702 break;
703
704 case EVENT_WMM_STATUS_CHANGE:
705 mwifiex_dbg(adapter, EVENT, "event: WMM status changed\n");
706 ret = mwifiex_send_cmd(priv, HostCmd_CMD_WMM_GET_STATUS,
707 0, 0, NULL, false);
708 break;
709
710 case EVENT_RSSI_LOW:
711 cfg80211_cqm_rssi_notify(priv->netdev,
712 NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
713 GFP_KERNEL);
714 mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
715 HostCmd_ACT_GEN_GET, 0, NULL, false);
716 priv->subsc_evt_rssi_state = RSSI_LOW_RECVD;
717 mwifiex_dbg(adapter, EVENT, "event: Beacon RSSI_LOW\n");
718 break;
719 case EVENT_SNR_LOW:
720 mwifiex_dbg(adapter, EVENT, "event: Beacon SNR_LOW\n");
721 break;
722 case EVENT_MAX_FAIL:
723 mwifiex_dbg(adapter, EVENT, "event: MAX_FAIL\n");
724 break;
725 case EVENT_RSSI_HIGH:
726 cfg80211_cqm_rssi_notify(priv->netdev,
727 NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
728 GFP_KERNEL);
729 mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
730 HostCmd_ACT_GEN_GET, 0, NULL, false);
731 priv->subsc_evt_rssi_state = RSSI_HIGH_RECVD;
732 mwifiex_dbg(adapter, EVENT, "event: Beacon RSSI_HIGH\n");
733 break;
734 case EVENT_SNR_HIGH:
735 mwifiex_dbg(adapter, EVENT, "event: Beacon SNR_HIGH\n");
736 break;
737 case EVENT_DATA_RSSI_LOW:
738 mwifiex_dbg(adapter, EVENT, "event: Data RSSI_LOW\n");
739 break;
740 case EVENT_DATA_SNR_LOW:
741 mwifiex_dbg(adapter, EVENT, "event: Data SNR_LOW\n");
742 break;
743 case EVENT_DATA_RSSI_HIGH:
744 mwifiex_dbg(adapter, EVENT, "event: Data RSSI_HIGH\n");
745 break;
746 case EVENT_DATA_SNR_HIGH:
747 mwifiex_dbg(adapter, EVENT, "event: Data SNR_HIGH\n");
748 break;
749 case EVENT_LINK_QUALITY:
750 mwifiex_dbg(adapter, EVENT, "event: Link Quality\n");
751 break;
752 case EVENT_PRE_BEACON_LOST:
753 mwifiex_dbg(adapter, EVENT, "event: Pre-Beacon Lost\n");
754 break;
755 case EVENT_IBSS_COALESCED:
756 mwifiex_dbg(adapter, EVENT, "event: IBSS_COALESCED\n");
757 ret = mwifiex_send_cmd(priv,
758 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
759 HostCmd_ACT_GEN_GET, 0, NULL, false);
760 break;
761 case EVENT_ADDBA:
762 mwifiex_dbg(adapter, EVENT, "event: ADDBA Request\n");
763 mwifiex_send_cmd(priv, HostCmd_CMD_11N_ADDBA_RSP,
764 HostCmd_ACT_GEN_SET, 0,
765 adapter->event_body, false);
766 break;
767 case EVENT_DELBA:
768 mwifiex_dbg(adapter, EVENT, "event: DELBA Request\n");
769 mwifiex_11n_delete_ba_stream(priv, adapter->event_body);
770 break;
771 case EVENT_BA_STREAM_TIEMOUT:
772 mwifiex_dbg(adapter, EVENT, "event: BA Stream timeout\n");
773 mwifiex_11n_ba_stream_timeout(priv,
774 (struct host_cmd_ds_11n_batimeout
775 *)
776 adapter->event_body);
777 break;
778 case EVENT_AMSDU_AGGR_CTRL:
779 ctrl = le16_to_cpu(*(__le16 *)adapter->event_body);
780 mwifiex_dbg(adapter, EVENT,
781 "event: AMSDU_AGGR_CTRL %d\n", ctrl);
782
783 adapter->tx_buf_size =
784 min_t(u16, adapter->curr_tx_buf_size, ctrl);
785 mwifiex_dbg(adapter, EVENT, "event: tx_buf_size %d\n",
786 adapter->tx_buf_size);
787 break;
788
789 case EVENT_WEP_ICV_ERR:
790 mwifiex_dbg(adapter, EVENT, "event: WEP ICV error\n");
791 break;
792
793 case EVENT_BW_CHANGE:
794 mwifiex_dbg(adapter, EVENT, "event: BW Change\n");
795 break;
796
797 case EVENT_HOSTWAKE_STAIE:
798 mwifiex_dbg(adapter, EVENT,
799 "event: HOSTWAKE_STAIE %d\n", eventcause);
800 break;
801
802 case EVENT_REMAIN_ON_CHAN_EXPIRED:
803 mwifiex_dbg(adapter, EVENT,
804 "event: Remain on channel expired\n");
805 cfg80211_remain_on_channel_expired(&priv->wdev,
806 priv->roc_cfg.cookie,
807 &priv->roc_cfg.chan,
808 GFP_ATOMIC);
809
810 memset(&priv->roc_cfg, 0x00, sizeof(struct mwifiex_roc_cfg));
811
812 break;
813
814 case EVENT_CHANNEL_SWITCH_ANN:
815 mwifiex_dbg(adapter, EVENT, "event: Channel Switch Announcement\n");
816 priv->csa_expire_time =
817 jiffies + msecs_to_jiffies(DFS_CHAN_MOVE_TIME);
818 priv->csa_chan = priv->curr_bss_params.bss_descriptor.channel;
819 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_DEAUTHENTICATE,
820 HostCmd_ACT_GEN_SET, 0,
821 priv->curr_bss_params.bss_descriptor.mac_address,
822 false);
823 break;
824
825 case EVENT_TDLS_GENERIC_EVENT:
826 ret = mwifiex_parse_tdls_event(priv, adapter->event_skb);
827 break;
828
829 case EVENT_TX_DATA_PAUSE:
830 mwifiex_dbg(adapter, EVENT, "event: TX DATA PAUSE\n");
831 mwifiex_process_tx_pause_event(priv, adapter->event_skb);
832 break;
833
834 case EVENT_MULTI_CHAN_INFO:
835 mwifiex_dbg(adapter, EVENT, "event: multi-chan info\n");
836 mwifiex_process_multi_chan_event(priv, adapter->event_skb);
837 break;
838
839 case EVENT_TX_STATUS_REPORT:
840 mwifiex_dbg(adapter, EVENT, "event: TX_STATUS Report\n");
841 mwifiex_parse_tx_status_event(priv, adapter->event_body);
842 break;
843
844 case EVENT_CHANNEL_REPORT_RDY:
845 mwifiex_dbg(adapter, EVENT, "event: Channel Report\n");
846 ret = mwifiex_11h_handle_chanrpt_ready(priv,
847 adapter->event_skb);
848 break;
849 case EVENT_RADAR_DETECTED:
850 mwifiex_dbg(adapter, EVENT, "event: Radar detected\n");
851 ret = mwifiex_11h_handle_radar_detected(priv,
852 adapter->event_skb);
853 break;
854 case EVENT_BT_COEX_WLAN_PARA_CHANGE:
855 dev_dbg(adapter->dev, "EVENT: BT coex wlan param update\n");
856 mwifiex_bt_coex_wlan_param_update_event(priv,
857 adapter->event_skb);
858 break;
859 default:
860 mwifiex_dbg(adapter, ERROR, "event: unknown event id: %#x\n",
861 eventcause);
862 break;
863 }
864
865 return ret;
866 }
867