blob: f1045d41abee8348d5c72124abc7942726052564 [file] [log] [blame]
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001/*
2 * Marvell Wireless LAN device driver: station event handling
3 *
Xinming Hu65da33f2014-06-19 21:38:57 -07004 * Copyright (C) 2011-2014, Marvell International Ltd.
Bing Zhao5e6e3a92011-03-21 18:00:50 -07005 *
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 */
43void
Amitkumar Karwar8cc1d522012-10-05 20:21:43 -070044mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code)
Bing Zhao5e6e3a92011-03-21 18:00:50 -070045{
46 struct mwifiex_adapter *adapter = priv->adapter;
47
48 if (!priv->media_connected)
49 return;
50
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +053051 mwifiex_dbg(adapter, INFO,
52 "info: handles disconnect event\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -070053
54 priv->media_connected = false;
55
56 priv->scan_block = false;
57
Avinash Patilbe104b92014-02-07 16:30:41 -080058 if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
Avinash Patil9927baa2014-11-13 21:54:16 +053059 ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info)) {
Avinash Patilbe104b92014-02-07 16:30:41 -080060 mwifiex_disable_all_tdls_links(priv);
61
Avinash Patil9927baa2014-11-13 21:54:16 +053062 if (priv->adapter->auto_tdls)
63 mwifiex_clean_auto_tdls(priv);
64 }
65
Bing Zhao5e6e3a92011-03-21 18:00:50 -070066 /* Free Tx and Rx packets, report disconnect to upper layer */
67 mwifiex_clean_txrx(priv);
68
69 /* Reset SNR/NF/RSSI values */
70 priv->data_rssi_last = 0;
71 priv->data_nf_last = 0;
72 priv->data_rssi_avg = 0;
73 priv->data_nf_avg = 0;
74 priv->bcn_rssi_last = 0;
75 priv->bcn_nf_last = 0;
76 priv->bcn_rssi_avg = 0;
77 priv->bcn_nf_avg = 0;
78 priv->rxpd_rate = 0;
79 priv->rxpd_htinfo = 0;
80 priv->sec_info.wpa_enabled = false;
81 priv->sec_info.wpa2_enabled = false;
82 priv->wpa_ie_len = 0;
83
84 priv->sec_info.wapi_enabled = false;
85 priv->wapi_ie_len = 0;
86 priv->sec_info.wapi_key_on = false;
87
Yogesh Ashok Powar2be50b82011-04-01 18:36:47 -070088 priv->sec_info.encryption_mode = 0;
Bing Zhao5e6e3a92011-03-21 18:00:50 -070089
90 /* Enable auto data rate */
91 priv->is_data_rate_auto = true;
92 priv->data_rate = 0;
93
Xinming Hucbf6e052014-12-23 19:14:07 +053094 if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA ||
95 GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) && priv->hist_data)
96 mwifiex_hist_data_reset(priv);
97
Bing Zhaoeecd8252011-03-28 17:55:41 -070098 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
Bing Zhao5e6e3a92011-03-21 18:00:50 -070099 priv->adhoc_state = ADHOC_IDLE;
100 priv->adhoc_is_link_sensed = false;
101 }
102
103 /*
104 * Memorize the previous SSID and BSSID so
105 * it could be used for re-assoc
106 */
107
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530108 mwifiex_dbg(adapter, INFO,
109 "info: previous SSID=%s, SSID len=%u\n",
110 priv->prev_ssid.ssid, priv->prev_ssid.ssid_len);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700111
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530112 mwifiex_dbg(adapter, INFO,
113 "info: current SSID=%s, SSID len=%u\n",
114 priv->curr_bss_params.bss_descriptor.ssid.ssid,
115 priv->curr_bss_params.bss_descriptor.ssid.ssid_len);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700116
117 memcpy(&priv->prev_ssid,
118 &priv->curr_bss_params.bss_descriptor.ssid,
Amitkumar Karwarb9be5f32012-02-27 22:04:14 -0800119 sizeof(struct cfg80211_ssid));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700120
121 memcpy(priv->prev_bssid,
122 priv->curr_bss_params.bss_descriptor.mac_address, ETH_ALEN);
123
124 /* Need to erase the current SSID and BSSID info */
125 memset(&priv->curr_bss_params, 0x00, sizeof(priv->curr_bss_params));
126
127 adapter->tx_lock_flag = false;
128 adapter->pps_uapsd_mode = false;
129
Amitkumar Karwar0c9c4a02014-02-27 19:35:17 -0800130 if (adapter->is_cmd_timedout && adapter->curr_cmd)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700131 return;
132 priv->media_connected = false;
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530133 mwifiex_dbg(adapter, MSG,
134 "info: successfully disconnected from %pM: reason code %d\n",
135 priv->cfg_bssid, reason_code);
Avinash Patil9612bd12013-10-11 18:31:32 -0700136 if (priv->bss_mode == NL80211_IFTYPE_STATION ||
137 priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) {
Amitkumar Karwar8cc1d522012-10-05 20:21:43 -0700138 cfg80211_disconnected(priv->netdev, reason_code, NULL, 0,
Johannes Berg80279fb2015-05-22 16:22:20 +0200139 false, GFP_KERNEL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700140 }
Joe Perches93803b32015-03-02 19:54:49 -0800141 eth_zero_addr(priv->cfg_bssid);
Amitkumar Karwar38c9d662011-12-13 20:43:17 -0800142
Avinash Patil47411a02012-11-01 18:44:16 -0700143 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700144 if (netif_carrier_ok(priv->netdev))
145 netif_carrier_off(priv->netdev);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700146}
147
Avinash Patil79ff4342014-05-06 22:02:44 -0700148static int mwifiex_parse_tdls_event(struct mwifiex_private *priv,
149 struct sk_buff *event_skb)
150{
Avinash Patilc1078bc2014-05-21 22:02:29 -0700151 int ret = 0;
Avinash Patil79ff4342014-05-06 22:02:44 -0700152 struct mwifiex_adapter *adapter = priv->adapter;
153 struct mwifiex_sta_node *sta_ptr;
154 struct mwifiex_tdls_generic_event *tdls_evt =
155 (void *)event_skb->data + sizeof(adapter->event_cause);
Xinming Huf7669872015-06-22 19:06:11 +0530156 u8 *mac = tdls_evt->peer_mac;
Avinash Patil79ff4342014-05-06 22:02:44 -0700157
158 /* reserved 2 bytes are not mandatory in tdls event */
159 if (event_skb->len < (sizeof(struct mwifiex_tdls_generic_event) -
160 sizeof(u16) - sizeof(adapter->event_cause))) {
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530161 mwifiex_dbg(adapter, ERROR, "Invalid event length!\n");
Avinash Patil79ff4342014-05-06 22:02:44 -0700162 return -1;
163 }
164
165 sta_ptr = mwifiex_get_sta_entry(priv, tdls_evt->peer_mac);
166 if (!sta_ptr) {
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530167 mwifiex_dbg(adapter, ERROR, "cannot get sta entry!\n");
Avinash Patil79ff4342014-05-06 22:02:44 -0700168 return -1;
169 }
170
171 switch (le16_to_cpu(tdls_evt->type)) {
172 case TDLS_EVENT_LINK_TEAR_DOWN:
173 cfg80211_tdls_oper_request(priv->netdev,
174 tdls_evt->peer_mac,
175 NL80211_TDLS_TEARDOWN,
176 le16_to_cpu(tdls_evt->u.reason_code),
177 GFP_KERNEL);
178 break;
Xinming Huf7669872015-06-22 19:06:11 +0530179 case TDLS_EVENT_CHAN_SWITCH_RESULT:
180 mwifiex_dbg(adapter, EVENT, "tdls channel switch result :\n");
181 mwifiex_dbg(adapter, EVENT,
182 "status=0x%x, reason=0x%x cur_chan=%d\n",
183 tdls_evt->u.switch_result.status,
184 tdls_evt->u.switch_result.reason,
185 tdls_evt->u.switch_result.cur_chan);
186
187 /* tdls channel switch failed */
188 if (tdls_evt->u.switch_result.status != 0) {
189 switch (tdls_evt->u.switch_result.cur_chan) {
190 case TDLS_BASE_CHANNEL:
191 sta_ptr->tdls_status = TDLS_IN_BASE_CHAN;
192 break;
193 case TDLS_OFF_CHANNEL:
194 sta_ptr->tdls_status = TDLS_IN_OFF_CHAN;
195 break;
196 default:
197 break;
198 }
199 return ret;
200 }
201
202 /* tdls channel switch success */
203 switch (tdls_evt->u.switch_result.cur_chan) {
204 case TDLS_BASE_CHANNEL:
205 if (sta_ptr->tdls_status == TDLS_IN_BASE_CHAN)
206 break;
207 mwifiex_update_ralist_tx_pause_in_tdls_cs(priv, mac,
208 false);
209 sta_ptr->tdls_status = TDLS_IN_BASE_CHAN;
210 break;
211 case TDLS_OFF_CHANNEL:
212 if (sta_ptr->tdls_status == TDLS_IN_OFF_CHAN)
213 break;
214 mwifiex_update_ralist_tx_pause_in_tdls_cs(priv, mac,
215 true);
216 sta_ptr->tdls_status = TDLS_IN_OFF_CHAN;
217 break;
218 default:
219 break;
220 }
221
222 break;
223 case TDLS_EVENT_START_CHAN_SWITCH:
224 mwifiex_dbg(adapter, EVENT, "tdls start channel switch...\n");
225 sta_ptr->tdls_status = TDLS_CHAN_SWITCHING;
226 break;
227 case TDLS_EVENT_CHAN_SWITCH_STOPPED:
228 mwifiex_dbg(adapter, EVENT,
229 "tdls chan switch stopped, reason=%d\n",
230 tdls_evt->u.cs_stop_reason);
231 break;
Avinash Patil79ff4342014-05-06 22:02:44 -0700232 default:
233 break;
234 }
235
Avinash Patilc1078bc2014-05-21 22:02:29 -0700236 return ret;
Avinash Patil79ff4342014-05-06 22:02:44 -0700237}
238
Avinash Patil4e6ee912015-06-22 19:06:07 +0530239static void
240mwifiex_process_sta_tx_pause_event(struct mwifiex_private *priv,
241 struct sk_buff *event_skb)
242{
243 struct mwifiex_ie_types_header *tlv;
244 struct mwifiex_tx_pause_tlv *tp_tlv;
245 struct mwifiex_sta_node *sta_ptr;
246 unsigned long flags;
247 u16 tlv_type, tlv_len;
248 int tlv_buf_left, status;
249
250 if (!ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info))
251 return;
252
253 if (!(priv->bss_type == MWIFIEX_BSS_TYPE_STA && priv->media_connected))
254 return;
255
256 tlv_buf_left = event_skb->len - sizeof(u32);
257 tlv = (void *)event_skb->data + sizeof(u32);
258 while (tlv_buf_left >= (int)sizeof(struct mwifiex_ie_types_header)) {
259 tlv_type = le16_to_cpu(tlv->type);
260 tlv_len = le16_to_cpu(tlv->len);
261 if ((sizeof(struct mwifiex_ie_types_header) + tlv_len) >
262 tlv_buf_left) {
263 mwifiex_dbg(priv->adapter, ERROR,
264 "wrong tlv: tlvLen=%d, tlvBufLeft=%d\n",
265 tlv_len, tlv_buf_left);
266 break;
267 }
268 if (tlv_type == TLV_TYPE_TX_PAUSE) {
269 tp_tlv = (void *)tlv;
270 mwifiex_dbg(priv->adapter, ERROR,
271 "TxPause: %pM pause=%d, pkts=%d\n",
272 tp_tlv->peermac, tp_tlv->tx_pause,
273 tp_tlv->pkt_cnt);
274 status = mwifiex_get_tdls_link_status
275 (priv, tp_tlv->peermac);
Xinming Hu55a2c072015-06-22 19:06:14 +0530276 if (mwifiex_is_tdls_link_setup(status)) {
Avinash Patil4e6ee912015-06-22 19:06:07 +0530277 spin_lock_irqsave(&priv->sta_list_spinlock,
278 flags);
279 sta_ptr = mwifiex_get_sta_entry
280 (priv, tp_tlv->peermac);
281 spin_unlock_irqrestore(&priv->sta_list_spinlock,
282 flags);
283 if (sta_ptr && sta_ptr->tx_pause !=
284 tp_tlv->tx_pause) {
285 sta_ptr->tx_pause = tp_tlv->tx_pause;
286 mwifiex_update_ralist_tx_pause
287 (priv, tp_tlv->peermac,
288 tp_tlv->tx_pause);
289 }
290 }
291 }
292
293 tlv_buf_left -= sizeof(struct mwifiex_ie_types_header) +
294 tlv_len;
295 tlv = (void *)((u8 *)tlv + tlv_len +
296 sizeof(struct mwifiex_ie_types_header));
297 }
298}
299
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700300/*
Chunfan Chend219b7e2015-06-10 06:19:48 -0700301* This function handles coex events generated by firmware
302*/
303void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv,
304 struct sk_buff *event_skb)
305{
306 struct mwifiex_adapter *adapter = priv->adapter;
307 struct mwifiex_ie_types_header *tlv;
308 struct mwifiex_ie_types_btcoex_aggr_win_size *winsizetlv;
309 struct mwifiex_ie_types_btcoex_scan_time *scantlv;
310 s32 len = event_skb->len - sizeof(u32);
311 u8 *cur_ptr = event_skb->data + sizeof(u32);
312 u16 tlv_type, tlv_len;
313
314 while (len >= sizeof(struct mwifiex_ie_types_header)) {
315 tlv = (struct mwifiex_ie_types_header *)cur_ptr;
316 tlv_len = le16_to_cpu(tlv->len);
317 tlv_type = le16_to_cpu(tlv->type);
318
319 if ((tlv_len + sizeof(struct mwifiex_ie_types_header)) > len)
320 break;
321 switch (tlv_type) {
322 case TLV_BTCOEX_WL_AGGR_WINSIZE:
323 winsizetlv =
324 (struct mwifiex_ie_types_btcoex_aggr_win_size *)tlv;
325 adapter->coex_win_size = winsizetlv->coex_win_size;
326 adapter->coex_tx_win_size =
327 winsizetlv->tx_win_size;
328 adapter->coex_rx_win_size =
329 winsizetlv->rx_win_size;
330 mwifiex_coex_ampdu_rxwinsize(adapter);
331 mwifiex_update_ampdu_txwinsize(adapter);
332 break;
333
334 case TLV_BTCOEX_WL_SCANTIME:
335 scantlv =
336 (struct mwifiex_ie_types_btcoex_scan_time *)tlv;
337 adapter->coex_scan = scantlv->coex_scan;
338 adapter->coex_min_scan_time = scantlv->min_scan_time;
339 adapter->coex_max_scan_time = scantlv->max_scan_time;
340 break;
341
342 default:
343 break;
344 }
345
346 len -= tlv_len + sizeof(struct mwifiex_ie_types_header);
347 cur_ptr += tlv_len +
348 sizeof(struct mwifiex_ie_types_header);
349 }
350
351 dev_dbg(adapter->dev, "coex_scan=%d min_scan=%d coex_win=%d, tx_win=%d rx_win=%d\n",
352 adapter->coex_scan, adapter->coex_min_scan_time,
353 adapter->coex_win_size, adapter->coex_tx_win_size,
354 adapter->coex_rx_win_size);
355}
356
357/*
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700358 * This function handles events generated by firmware.
359 *
360 * This is a generic function and handles all events.
361 *
362 * Event specific routines are called by this function based
363 * upon the generated event cause.
364 *
365 * For the following events, the function just forwards them to upper
366 * layers, optionally recording the change -
367 * - EVENT_LINK_SENSED
368 * - EVENT_MIC_ERR_UNICAST
369 * - EVENT_MIC_ERR_MULTICAST
370 * - EVENT_PORT_RELEASE
371 * - EVENT_RSSI_LOW
372 * - EVENT_SNR_LOW
373 * - EVENT_MAX_FAIL
374 * - EVENT_RSSI_HIGH
375 * - EVENT_SNR_HIGH
376 * - EVENT_DATA_RSSI_LOW
377 * - EVENT_DATA_SNR_LOW
378 * - EVENT_DATA_RSSI_HIGH
379 * - EVENT_DATA_SNR_HIGH
380 * - EVENT_LINK_QUALITY
381 * - EVENT_PRE_BEACON_LOST
382 * - EVENT_IBSS_COALESCED
383 * - EVENT_WEP_ICV_ERR
384 * - EVENT_BW_CHANGE
385 * - EVENT_HOSTWAKE_STAIE
386 *
387 * For the following events, no action is taken -
388 * - EVENT_MIB_CHANGED
389 * - EVENT_INIT_DONE
390 * - EVENT_DUMMY_HOST_WAKEUP_SIGNAL
391 *
392 * Rest of the supported events requires driver handling -
393 * - EVENT_DEAUTHENTICATED
394 * - EVENT_DISASSOCIATED
395 * - EVENT_LINK_LOST
396 * - EVENT_PS_SLEEP
397 * - EVENT_PS_AWAKE
398 * - EVENT_DEEP_SLEEP_AWAKE
399 * - EVENT_HS_ACT_REQ
400 * - EVENT_ADHOC_BCN_LOST
401 * - EVENT_BG_SCAN_REPORT
402 * - EVENT_WMM_STATUS_CHANGE
403 * - EVENT_ADDBA
404 * - EVENT_DELBA
405 * - EVENT_BA_STREAM_TIEMOUT
406 * - EVENT_AMSDU_AGGR_CTRL
407 */
408int mwifiex_process_sta_event(struct mwifiex_private *priv)
409{
410 struct mwifiex_adapter *adapter = priv->adapter;
Avinash Patil3d99d982012-08-03 18:06:06 -0700411 int ret = 0;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700412 u32 eventcause = adapter->event_cause;
Amitkumar Karwar8cc1d522012-10-05 20:21:43 -0700413 u16 ctrl, reason_code;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700414
415 switch (eventcause) {
416 case EVENT_DUMMY_HOST_WAKEUP_SIGNAL:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530417 mwifiex_dbg(adapter, ERROR,
418 "invalid EVENT: DUMMY_HOST_WAKEUP_SIGNAL, ignore it\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700419 break;
420 case EVENT_LINK_SENSED:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530421 mwifiex_dbg(adapter, EVENT, "event: LINK_SENSED\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700422 if (!netif_carrier_ok(priv->netdev))
423 netif_carrier_on(priv->netdev);
Avinash Patil47411a02012-11-01 18:44:16 -0700424 mwifiex_wake_up_net_dev_queue(priv->netdev, adapter);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700425 break;
426
427 case EVENT_DEAUTHENTICATED:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530428 mwifiex_dbg(adapter, EVENT, "event: Deauthenticated\n");
Stone Piaoeaf49db2013-07-22 19:17:43 -0700429 if (priv->wps.session_enable) {
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530430 mwifiex_dbg(adapter, INFO,
431 "info: receive deauth event in wps session\n");
Stone Piaoeaf49db2013-07-22 19:17:43 -0700432 break;
433 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700434 adapter->dbg.num_event_deauth++;
Amitkumar Karwar8cc1d522012-10-05 20:21:43 -0700435 if (priv->media_connected) {
436 reason_code =
437 le16_to_cpu(*(__le16 *)adapter->event_body);
438 mwifiex_reset_connect_state(priv, reason_code);
439 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700440 break;
441
442 case EVENT_DISASSOCIATED:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530443 mwifiex_dbg(adapter, EVENT, "event: Disassociated\n");
Stone Piaoeaf49db2013-07-22 19:17:43 -0700444 if (priv->wps.session_enable) {
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530445 mwifiex_dbg(adapter, INFO,
446 "info: receive disassoc event in wps session\n");
Stone Piaoeaf49db2013-07-22 19:17:43 -0700447 break;
448 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700449 adapter->dbg.num_event_disassoc++;
Amitkumar Karwar8cc1d522012-10-05 20:21:43 -0700450 if (priv->media_connected) {
451 reason_code =
452 le16_to_cpu(*(__le16 *)adapter->event_body);
453 mwifiex_reset_connect_state(priv, reason_code);
454 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700455 break;
456
457 case EVENT_LINK_LOST:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530458 mwifiex_dbg(adapter, EVENT, "event: Link lost\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700459 adapter->dbg.num_event_link_lost++;
Amitkumar Karwar8cc1d522012-10-05 20:21:43 -0700460 if (priv->media_connected) {
461 reason_code =
462 le16_to_cpu(*(__le16 *)adapter->event_body);
463 mwifiex_reset_connect_state(priv, reason_code);
464 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700465 break;
466
467 case EVENT_PS_SLEEP:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530468 mwifiex_dbg(adapter, EVENT, "info: EVENT: SLEEP\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700469
470 adapter->ps_state = PS_STATE_PRE_SLEEP;
471
472 mwifiex_check_ps_cond(adapter);
473 break;
474
475 case EVENT_PS_AWAKE:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530476 mwifiex_dbg(adapter, EVENT, "info: EVENT: AWAKE\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700477 if (!adapter->pps_uapsd_mode &&
Yogesh Ashok Powar500f7472012-03-13 19:22:41 -0700478 priv->media_connected && adapter->sleep_period.period) {
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700479 adapter->pps_uapsd_mode = true;
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530480 mwifiex_dbg(adapter, EVENT,
481 "event: PPS/UAPSD mode activated\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700482 }
483 adapter->tx_lock_flag = false;
484 if (adapter->pps_uapsd_mode && adapter->gen_null_pkt) {
485 if (mwifiex_check_last_packet_indication(priv)) {
Yogesh Ashok Powar500f7472012-03-13 19:22:41 -0700486 if (adapter->data_sent) {
487 adapter->ps_state = PS_STATE_AWAKE;
488 adapter->pm_wakeup_card_req = false;
489 adapter->pm_wakeup_fw_try = false;
Amitkumar Karwar6e9344f2015-03-12 00:38:40 -0700490 del_timer(&adapter->wakeup_timer);
Yogesh Ashok Powar500f7472012-03-13 19:22:41 -0700491 break;
492 }
493 if (!mwifiex_send_null_packet
494 (priv,
495 MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET |
496 MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET))
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700497 adapter->ps_state =
498 PS_STATE_SLEEP;
499 return 0;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700500 }
501 }
502 adapter->ps_state = PS_STATE_AWAKE;
503 adapter->pm_wakeup_card_req = false;
504 adapter->pm_wakeup_fw_try = false;
Amitkumar Karwar6e9344f2015-03-12 00:38:40 -0700505 del_timer(&adapter->wakeup_timer);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700506
507 break;
508
509 case EVENT_DEEP_SLEEP_AWAKE:
510 adapter->if_ops.wakeup_complete(adapter);
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530511 mwifiex_dbg(adapter, EVENT, "event: DS_AWAKE\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700512 if (adapter->is_deep_sleep)
513 adapter->is_deep_sleep = false;
514 break;
515
516 case EVENT_HS_ACT_REQ:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530517 mwifiex_dbg(adapter, EVENT, "event: HS_ACT_REQ\n");
Bing Zhaofa0ecbb2014-02-27 19:35:12 -0800518 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_HS_CFG_ENH,
519 0, 0, NULL, false);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700520 break;
521
522 case EVENT_MIC_ERR_UNICAST:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530523 mwifiex_dbg(adapter, EVENT, "event: UNICAST MIC ERROR\n");
Amitkumar Karwar9c7ff732012-08-08 19:02:56 -0700524 cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid,
525 NL80211_KEYTYPE_PAIRWISE,
526 -1, NULL, GFP_KERNEL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700527 break;
528
529 case EVENT_MIC_ERR_MULTICAST:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530530 mwifiex_dbg(adapter, EVENT, "event: MULTICAST MIC ERROR\n");
Amitkumar Karwar9c7ff732012-08-08 19:02:56 -0700531 cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid,
532 NL80211_KEYTYPE_GROUP,
533 -1, NULL, GFP_KERNEL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700534 break;
535 case EVENT_MIB_CHANGED:
536 case EVENT_INIT_DONE:
537 break;
538
539 case EVENT_ADHOC_BCN_LOST:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530540 mwifiex_dbg(adapter, EVENT, "event: ADHOC_BCN_LOST\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700541 priv->adhoc_is_link_sensed = false;
542 mwifiex_clean_txrx(priv);
Avinash Patil47411a02012-11-01 18:44:16 -0700543 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700544 if (netif_carrier_ok(priv->netdev))
545 netif_carrier_off(priv->netdev);
546 break;
547
548 case EVENT_BG_SCAN_REPORT:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530549 mwifiex_dbg(adapter, EVENT, "event: BGS_REPORT\n");
Bing Zhaofa0ecbb2014-02-27 19:35:12 -0800550 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_BG_SCAN_QUERY,
551 HostCmd_ACT_GEN_GET, 0, NULL, false);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700552 break;
553
554 case EVENT_PORT_RELEASE:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530555 mwifiex_dbg(adapter, EVENT, "event: PORT RELEASE\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700556 break;
557
Amitkumar Karwar21f58d202014-02-11 18:39:56 -0800558 case EVENT_EXT_SCAN_REPORT:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530559 mwifiex_dbg(adapter, EVENT, "event: EXT_SCAN Report\n");
Amitkumar Karwar21f58d202014-02-11 18:39:56 -0800560 if (adapter->ext_scan)
561 ret = mwifiex_handle_event_ext_scan_report(priv,
562 adapter->event_skb->data);
563
564 break;
565
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700566 case EVENT_WMM_STATUS_CHANGE:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530567 mwifiex_dbg(adapter, EVENT, "event: WMM status changed\n");
Bing Zhaofa0ecbb2014-02-27 19:35:12 -0800568 ret = mwifiex_send_cmd(priv, HostCmd_CMD_WMM_GET_STATUS,
569 0, 0, NULL, false);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700570 break;
571
572 case EVENT_RSSI_LOW:
Amitkumar Karwarfa444bf2012-03-15 20:51:51 -0700573 cfg80211_cqm_rssi_notify(priv->netdev,
574 NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
575 GFP_KERNEL);
Bing Zhaofa0ecbb2014-02-27 19:35:12 -0800576 mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
577 HostCmd_ACT_GEN_GET, 0, NULL, false);
Amitkumar Karwarfa444bf2012-03-15 20:51:51 -0700578 priv->subsc_evt_rssi_state = RSSI_LOW_RECVD;
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530579 mwifiex_dbg(adapter, EVENT, "event: Beacon RSSI_LOW\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700580 break;
581 case EVENT_SNR_LOW:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530582 mwifiex_dbg(adapter, EVENT, "event: Beacon SNR_LOW\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700583 break;
584 case EVENT_MAX_FAIL:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530585 mwifiex_dbg(adapter, EVENT, "event: MAX_FAIL\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700586 break;
587 case EVENT_RSSI_HIGH:
Amitkumar Karwarfa444bf2012-03-15 20:51:51 -0700588 cfg80211_cqm_rssi_notify(priv->netdev,
589 NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
590 GFP_KERNEL);
Bing Zhaofa0ecbb2014-02-27 19:35:12 -0800591 mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
592 HostCmd_ACT_GEN_GET, 0, NULL, false);
Amitkumar Karwarfa444bf2012-03-15 20:51:51 -0700593 priv->subsc_evt_rssi_state = RSSI_HIGH_RECVD;
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530594 mwifiex_dbg(adapter, EVENT, "event: Beacon RSSI_HIGH\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700595 break;
596 case EVENT_SNR_HIGH:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530597 mwifiex_dbg(adapter, EVENT, "event: Beacon SNR_HIGH\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700598 break;
599 case EVENT_DATA_RSSI_LOW:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530600 mwifiex_dbg(adapter, EVENT, "event: Data RSSI_LOW\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700601 break;
602 case EVENT_DATA_SNR_LOW:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530603 mwifiex_dbg(adapter, EVENT, "event: Data SNR_LOW\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700604 break;
605 case EVENT_DATA_RSSI_HIGH:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530606 mwifiex_dbg(adapter, EVENT, "event: Data RSSI_HIGH\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700607 break;
608 case EVENT_DATA_SNR_HIGH:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530609 mwifiex_dbg(adapter, EVENT, "event: Data SNR_HIGH\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700610 break;
611 case EVENT_LINK_QUALITY:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530612 mwifiex_dbg(adapter, EVENT, "event: Link Quality\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700613 break;
614 case EVENT_PRE_BEACON_LOST:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530615 mwifiex_dbg(adapter, EVENT, "event: Pre-Beacon Lost\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700616 break;
617 case EVENT_IBSS_COALESCED:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530618 mwifiex_dbg(adapter, EVENT, "event: IBSS_COALESCED\n");
Bing Zhaofa0ecbb2014-02-27 19:35:12 -0800619 ret = mwifiex_send_cmd(priv,
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700620 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
Bing Zhaofa0ecbb2014-02-27 19:35:12 -0800621 HostCmd_ACT_GEN_GET, 0, NULL, false);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700622 break;
623 case EVENT_ADDBA:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530624 mwifiex_dbg(adapter, EVENT, "event: ADDBA Request\n");
Bing Zhaofa0ecbb2014-02-27 19:35:12 -0800625 mwifiex_send_cmd(priv, HostCmd_CMD_11N_ADDBA_RSP,
626 HostCmd_ACT_GEN_SET, 0,
627 adapter->event_body, false);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700628 break;
629 case EVENT_DELBA:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530630 mwifiex_dbg(adapter, EVENT, "event: DELBA Request\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700631 mwifiex_11n_delete_ba_stream(priv, adapter->event_body);
632 break;
633 case EVENT_BA_STREAM_TIEMOUT:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530634 mwifiex_dbg(adapter, EVENT, "event: BA Stream timeout\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700635 mwifiex_11n_ba_stream_timeout(priv,
636 (struct host_cmd_ds_11n_batimeout
637 *)
638 adapter->event_body);
639 break;
640 case EVENT_AMSDU_AGGR_CTRL:
Bing Zhao8dd43722012-08-07 16:08:08 -0700641 ctrl = le16_to_cpu(*(__le16 *)adapter->event_body);
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530642 mwifiex_dbg(adapter, EVENT,
643 "event: AMSDU_AGGR_CTRL %d\n", ctrl);
Bing Zhao8dd43722012-08-07 16:08:08 -0700644
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700645 adapter->tx_buf_size =
Bing Zhao8dd43722012-08-07 16:08:08 -0700646 min_t(u16, adapter->curr_tx_buf_size, ctrl);
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530647 mwifiex_dbg(adapter, EVENT, "event: tx_buf_size %d\n",
648 adapter->tx_buf_size);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700649 break;
650
651 case EVENT_WEP_ICV_ERR:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530652 mwifiex_dbg(adapter, EVENT, "event: WEP ICV error\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700653 break;
654
655 case EVENT_BW_CHANGE:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530656 mwifiex_dbg(adapter, EVENT, "event: BW Change\n");
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700657 break;
658
659 case EVENT_HOSTWAKE_STAIE:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530660 mwifiex_dbg(adapter, EVENT,
661 "event: HOSTWAKE_STAIE %d\n", eventcause);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700662 break;
Avinash Patile5686342012-05-08 18:30:25 -0700663
Stone Piaoeab1c762012-09-25 20:23:37 -0700664 case EVENT_REMAIN_ON_CHAN_EXPIRED:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530665 mwifiex_dbg(adapter, EVENT,
666 "event: Remain on channel expired\n");
Avinash Patil4facc342015-01-28 15:42:00 +0530667 cfg80211_remain_on_channel_expired(&priv->wdev,
Stone Piaoeab1c762012-09-25 20:23:37 -0700668 priv->roc_cfg.cookie,
669 &priv->roc_cfg.chan,
Stone Piaoeab1c762012-09-25 20:23:37 -0700670 GFP_ATOMIC);
671
672 memset(&priv->roc_cfg, 0x00, sizeof(struct mwifiex_roc_cfg));
673
674 break;
675
Amitkumar Karwar2a7305c2013-06-19 08:49:05 -0700676 case EVENT_CHANNEL_SWITCH_ANN:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530677 mwifiex_dbg(adapter, EVENT, "event: Channel Switch Announcement\n");
Amitkumar Karwarb8876642013-06-18 16:36:58 -0700678 priv->csa_expire_time =
679 jiffies + msecs_to_jiffies(DFS_CHAN_MOVE_TIME);
680 priv->csa_chan = priv->curr_bss_params.bss_descriptor.channel;
Bing Zhaofa0ecbb2014-02-27 19:35:12 -0800681 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_DEAUTHENTICATE,
Amitkumar Karwar2a7305c2013-06-19 08:49:05 -0700682 HostCmd_ACT_GEN_SET, 0,
Bing Zhaofa0ecbb2014-02-27 19:35:12 -0800683 priv->curr_bss_params.bss_descriptor.mac_address,
684 false);
Amitkumar Karwar2a7305c2013-06-19 08:49:05 -0700685 break;
686
Avinash Patil79ff4342014-05-06 22:02:44 -0700687 case EVENT_TDLS_GENERIC_EVENT:
688 ret = mwifiex_parse_tdls_event(priv, adapter->event_skb);
689 break;
690
Avinash Patil4e6ee912015-06-22 19:06:07 +0530691 case EVENT_TX_DATA_PAUSE:
692 mwifiex_process_sta_tx_pause_event(priv, adapter->event_skb);
693 mwifiex_dbg(adapter, EVENT, "event: TX DATA PAUSE\n");
694 break;
695
Amitkumar Karwar808bbeb2014-11-25 06:43:05 -0800696 case EVENT_TX_STATUS_REPORT:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530697 mwifiex_dbg(adapter, EVENT, "event: TX_STATUS Report\n");
Amitkumar Karwar808bbeb2014-11-25 06:43:05 -0800698 mwifiex_parse_tx_status_event(priv, adapter->event_body);
699 break;
700
Avinash Patil0a694d62015-01-28 15:54:22 +0530701 case EVENT_CHANNEL_REPORT_RDY:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530702 mwifiex_dbg(adapter, EVENT, "event: Channel Report\n");
Avinash Patil0a694d62015-01-28 15:54:22 +0530703 ret = mwifiex_11h_handle_chanrpt_ready(priv,
704 adapter->event_skb);
705 break;
Avinash Patil3b57c1a2015-01-28 15:54:23 +0530706 case EVENT_RADAR_DETECTED:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530707 mwifiex_dbg(adapter, EVENT, "event: Radar detected\n");
Avinash Patil3b57c1a2015-01-28 15:54:23 +0530708 ret = mwifiex_11h_handle_radar_detected(priv,
709 adapter->event_skb);
710 break;
Chunfan Chend219b7e2015-06-10 06:19:48 -0700711 case EVENT_BT_COEX_WLAN_PARA_CHANGE:
712 dev_dbg(adapter->dev, "EVENT: BT coex wlan param update\n");
713 mwifiex_bt_coex_wlan_param_update_event(priv,
714 adapter->event_skb);
Amitkumar Karwar323d8f12015-06-15 04:03:35 -0700715 break;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700716 default:
Zhaoyang Liuacebe8c2015-05-12 00:48:20 +0530717 mwifiex_dbg(adapter, ERROR, "event: unknown event id: %#x\n",
718 eventcause);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700719 break;
720 }
721
722 return ret;
723}