cfg80211: remove 80+80 MHz rate reporting
[deliverable/linux.git] / drivers / net / wireless / mwifiex / sta_event.c
CommitLineData
5e6e3a92
BZ
1/*
2 * Marvell Wireless LAN device driver: station event handling
3 *
65da33f5 4 * Copyright (C) 2011-2014, Marvell International Ltd.
5e6e3a92
BZ
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 */
43void
8cc1d523 44mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code)
5e6e3a92
BZ
45{
46 struct mwifiex_adapter *adapter = priv->adapter;
47
48 if (!priv->media_connected)
49 return;
50
51 dev_dbg(adapter->dev, "info: handles disconnect event\n");
52
53 priv->media_connected = false;
54
55 priv->scan_block = false;
56
be104b91 57 if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
9927baa3 58 ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info)) {
be104b91
AP
59 mwifiex_disable_all_tdls_links(priv);
60
9927baa3
AP
61 if (priv->adapter->auto_tdls)
62 mwifiex_clean_auto_tdls(priv);
63 }
64
5e6e3a92
BZ
65 /* Free Tx and Rx packets, report disconnect to upper layer */
66 mwifiex_clean_txrx(priv);
67
68 /* Reset SNR/NF/RSSI values */
69 priv->data_rssi_last = 0;
70 priv->data_nf_last = 0;
71 priv->data_rssi_avg = 0;
72 priv->data_nf_avg = 0;
73 priv->bcn_rssi_last = 0;
74 priv->bcn_nf_last = 0;
75 priv->bcn_rssi_avg = 0;
76 priv->bcn_nf_avg = 0;
77 priv->rxpd_rate = 0;
78 priv->rxpd_htinfo = 0;
79 priv->sec_info.wpa_enabled = false;
80 priv->sec_info.wpa2_enabled = false;
81 priv->wpa_ie_len = 0;
82
83 priv->sec_info.wapi_enabled = false;
84 priv->wapi_ie_len = 0;
85 priv->sec_info.wapi_key_on = false;
86
2be50b8d 87 priv->sec_info.encryption_mode = 0;
5e6e3a92
BZ
88
89 /* Enable auto data rate */
90 priv->is_data_rate_auto = true;
91 priv->data_rate = 0;
92
eecd8250 93 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
5e6e3a92
BZ
94 priv->adhoc_state = ADHOC_IDLE;
95 priv->adhoc_is_link_sensed = false;
96 }
97
98 /*
99 * Memorize the previous SSID and BSSID so
100 * it could be used for re-assoc
101 */
102
103 dev_dbg(adapter->dev, "info: previous SSID=%s, SSID len=%u\n",
500f747c 104 priv->prev_ssid.ssid, priv->prev_ssid.ssid_len);
5e6e3a92
BZ
105
106 dev_dbg(adapter->dev, "info: current SSID=%s, SSID len=%u\n",
500f747c
YAP
107 priv->curr_bss_params.bss_descriptor.ssid.ssid,
108 priv->curr_bss_params.bss_descriptor.ssid.ssid_len);
5e6e3a92
BZ
109
110 memcpy(&priv->prev_ssid,
111 &priv->curr_bss_params.bss_descriptor.ssid,
b9be5f39 112 sizeof(struct cfg80211_ssid));
5e6e3a92
BZ
113
114 memcpy(priv->prev_bssid,
115 priv->curr_bss_params.bss_descriptor.mac_address, ETH_ALEN);
116
117 /* Need to erase the current SSID and BSSID info */
118 memset(&priv->curr_bss_params, 0x00, sizeof(priv->curr_bss_params));
119
120 adapter->tx_lock_flag = false;
121 adapter->pps_uapsd_mode = false;
122
0c9c4a09 123 if (adapter->is_cmd_timedout && adapter->curr_cmd)
5e6e3a92
BZ
124 return;
125 priv->media_connected = false;
500f747c
YAP
126 dev_dbg(adapter->dev,
127 "info: successfully disconnected from %pM: reason code %d\n",
8cc1d523 128 priv->cfg_bssid, reason_code);
9612bd1e
AP
129 if (priv->bss_mode == NL80211_IFTYPE_STATION ||
130 priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) {
8cc1d523
AK
131 cfg80211_disconnected(priv->netdev, reason_code, NULL, 0,
132 GFP_KERNEL);
5e6e3a92 133 }
38c9d664
AK
134 memset(priv->cfg_bssid, 0, ETH_ALEN);
135
47411a06 136 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
5e6e3a92
BZ
137 if (netif_carrier_ok(priv->netdev))
138 netif_carrier_off(priv->netdev);
5e6e3a92
BZ
139}
140
79ff4346
AP
141static int mwifiex_parse_tdls_event(struct mwifiex_private *priv,
142 struct sk_buff *event_skb)
143{
c1078bc9 144 int ret = 0;
79ff4346
AP
145 struct mwifiex_adapter *adapter = priv->adapter;
146 struct mwifiex_sta_node *sta_ptr;
147 struct mwifiex_tdls_generic_event *tdls_evt =
148 (void *)event_skb->data + sizeof(adapter->event_cause);
149
150 /* reserved 2 bytes are not mandatory in tdls event */
151 if (event_skb->len < (sizeof(struct mwifiex_tdls_generic_event) -
152 sizeof(u16) - sizeof(adapter->event_cause))) {
153 dev_err(adapter->dev, "Invalid event length!\n");
154 return -1;
155 }
156
157 sta_ptr = mwifiex_get_sta_entry(priv, tdls_evt->peer_mac);
158 if (!sta_ptr) {
159 dev_err(adapter->dev, "cannot get sta entry!\n");
160 return -1;
161 }
162
163 switch (le16_to_cpu(tdls_evt->type)) {
164 case TDLS_EVENT_LINK_TEAR_DOWN:
165 cfg80211_tdls_oper_request(priv->netdev,
166 tdls_evt->peer_mac,
167 NL80211_TDLS_TEARDOWN,
168 le16_to_cpu(tdls_evt->u.reason_code),
169 GFP_KERNEL);
170 break;
171 default:
172 break;
173 }
174
c1078bc9 175 return ret;
79ff4346
AP
176}
177
5e6e3a92
BZ
178/*
179 * This function handles events generated by firmware.
180 *
181 * This is a generic function and handles all events.
182 *
183 * Event specific routines are called by this function based
184 * upon the generated event cause.
185 *
186 * For the following events, the function just forwards them to upper
187 * layers, optionally recording the change -
188 * - EVENT_LINK_SENSED
189 * - EVENT_MIC_ERR_UNICAST
190 * - EVENT_MIC_ERR_MULTICAST
191 * - EVENT_PORT_RELEASE
192 * - EVENT_RSSI_LOW
193 * - EVENT_SNR_LOW
194 * - EVENT_MAX_FAIL
195 * - EVENT_RSSI_HIGH
196 * - EVENT_SNR_HIGH
197 * - EVENT_DATA_RSSI_LOW
198 * - EVENT_DATA_SNR_LOW
199 * - EVENT_DATA_RSSI_HIGH
200 * - EVENT_DATA_SNR_HIGH
201 * - EVENT_LINK_QUALITY
202 * - EVENT_PRE_BEACON_LOST
203 * - EVENT_IBSS_COALESCED
204 * - EVENT_WEP_ICV_ERR
205 * - EVENT_BW_CHANGE
206 * - EVENT_HOSTWAKE_STAIE
207 *
208 * For the following events, no action is taken -
209 * - EVENT_MIB_CHANGED
210 * - EVENT_INIT_DONE
211 * - EVENT_DUMMY_HOST_WAKEUP_SIGNAL
212 *
213 * Rest of the supported events requires driver handling -
214 * - EVENT_DEAUTHENTICATED
215 * - EVENT_DISASSOCIATED
216 * - EVENT_LINK_LOST
217 * - EVENT_PS_SLEEP
218 * - EVENT_PS_AWAKE
219 * - EVENT_DEEP_SLEEP_AWAKE
220 * - EVENT_HS_ACT_REQ
221 * - EVENT_ADHOC_BCN_LOST
222 * - EVENT_BG_SCAN_REPORT
223 * - EVENT_WMM_STATUS_CHANGE
224 * - EVENT_ADDBA
225 * - EVENT_DELBA
226 * - EVENT_BA_STREAM_TIEMOUT
227 * - EVENT_AMSDU_AGGR_CTRL
228 */
229int mwifiex_process_sta_event(struct mwifiex_private *priv)
230{
231 struct mwifiex_adapter *adapter = priv->adapter;
3d99d987 232 int ret = 0;
5e6e3a92 233 u32 eventcause = adapter->event_cause;
8cc1d523 234 u16 ctrl, reason_code;
5e6e3a92
BZ
235
236 switch (eventcause) {
237 case EVENT_DUMMY_HOST_WAKEUP_SIGNAL:
500f747c
YAP
238 dev_err(adapter->dev,
239 "invalid EVENT: DUMMY_HOST_WAKEUP_SIGNAL, ignore it\n");
5e6e3a92
BZ
240 break;
241 case EVENT_LINK_SENSED:
242 dev_dbg(adapter->dev, "event: LINK_SENSED\n");
243 if (!netif_carrier_ok(priv->netdev))
244 netif_carrier_on(priv->netdev);
47411a06 245 mwifiex_wake_up_net_dev_queue(priv->netdev, adapter);
5e6e3a92
BZ
246 break;
247
248 case EVENT_DEAUTHENTICATED:
249 dev_dbg(adapter->dev, "event: Deauthenticated\n");
eaf49dbc
SP
250 if (priv->wps.session_enable) {
251 dev_dbg(adapter->dev,
252 "info: receive deauth event in wps session\n");
253 break;
254 }
5e6e3a92 255 adapter->dbg.num_event_deauth++;
8cc1d523
AK
256 if (priv->media_connected) {
257 reason_code =
258 le16_to_cpu(*(__le16 *)adapter->event_body);
259 mwifiex_reset_connect_state(priv, reason_code);
260 }
5e6e3a92
BZ
261 break;
262
263 case EVENT_DISASSOCIATED:
264 dev_dbg(adapter->dev, "event: Disassociated\n");
eaf49dbc
SP
265 if (priv->wps.session_enable) {
266 dev_dbg(adapter->dev,
267 "info: receive disassoc event in wps session\n");
268 break;
269 }
5e6e3a92 270 adapter->dbg.num_event_disassoc++;
8cc1d523
AK
271 if (priv->media_connected) {
272 reason_code =
273 le16_to_cpu(*(__le16 *)adapter->event_body);
274 mwifiex_reset_connect_state(priv, reason_code);
275 }
5e6e3a92
BZ
276 break;
277
278 case EVENT_LINK_LOST:
279 dev_dbg(adapter->dev, "event: Link lost\n");
280 adapter->dbg.num_event_link_lost++;
8cc1d523
AK
281 if (priv->media_connected) {
282 reason_code =
283 le16_to_cpu(*(__le16 *)adapter->event_body);
284 mwifiex_reset_connect_state(priv, reason_code);
285 }
5e6e3a92
BZ
286 break;
287
288 case EVENT_PS_SLEEP:
289 dev_dbg(adapter->dev, "info: EVENT: SLEEP\n");
290
291 adapter->ps_state = PS_STATE_PRE_SLEEP;
292
293 mwifiex_check_ps_cond(adapter);
294 break;
295
296 case EVENT_PS_AWAKE:
297 dev_dbg(adapter->dev, "info: EVENT: AWAKE\n");
298 if (!adapter->pps_uapsd_mode &&
500f747c 299 priv->media_connected && adapter->sleep_period.period) {
5e6e3a92
BZ
300 adapter->pps_uapsd_mode = true;
301 dev_dbg(adapter->dev,
302 "event: PPS/UAPSD mode activated\n");
303 }
304 adapter->tx_lock_flag = false;
305 if (adapter->pps_uapsd_mode && adapter->gen_null_pkt) {
306 if (mwifiex_check_last_packet_indication(priv)) {
500f747c
YAP
307 if (adapter->data_sent) {
308 adapter->ps_state = PS_STATE_AWAKE;
309 adapter->pm_wakeup_card_req = false;
310 adapter->pm_wakeup_fw_try = false;
311 break;
312 }
313 if (!mwifiex_send_null_packet
314 (priv,
315 MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET |
316 MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET))
5e6e3a92
BZ
317 adapter->ps_state =
318 PS_STATE_SLEEP;
319 return 0;
5e6e3a92
BZ
320 }
321 }
322 adapter->ps_state = PS_STATE_AWAKE;
323 adapter->pm_wakeup_card_req = false;
324 adapter->pm_wakeup_fw_try = false;
325
326 break;
327
328 case EVENT_DEEP_SLEEP_AWAKE:
329 adapter->if_ops.wakeup_complete(adapter);
330 dev_dbg(adapter->dev, "event: DS_AWAKE\n");
331 if (adapter->is_deep_sleep)
332 adapter->is_deep_sleep = false;
333 break;
334
335 case EVENT_HS_ACT_REQ:
336 dev_dbg(adapter->dev, "event: HS_ACT_REQ\n");
fa0ecbb9
BZ
337 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_HS_CFG_ENH,
338 0, 0, NULL, false);
5e6e3a92
BZ
339 break;
340
341 case EVENT_MIC_ERR_UNICAST:
342 dev_dbg(adapter->dev, "event: UNICAST MIC ERROR\n");
9c7ff737
AK
343 cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid,
344 NL80211_KEYTYPE_PAIRWISE,
345 -1, NULL, GFP_KERNEL);
5e6e3a92
BZ
346 break;
347
348 case EVENT_MIC_ERR_MULTICAST:
349 dev_dbg(adapter->dev, "event: MULTICAST MIC ERROR\n");
9c7ff737
AK
350 cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid,
351 NL80211_KEYTYPE_GROUP,
352 -1, NULL, GFP_KERNEL);
5e6e3a92
BZ
353 break;
354 case EVENT_MIB_CHANGED:
355 case EVENT_INIT_DONE:
356 break;
357
358 case EVENT_ADHOC_BCN_LOST:
359 dev_dbg(adapter->dev, "event: ADHOC_BCN_LOST\n");
360 priv->adhoc_is_link_sensed = false;
361 mwifiex_clean_txrx(priv);
47411a06 362 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
5e6e3a92
BZ
363 if (netif_carrier_ok(priv->netdev))
364 netif_carrier_off(priv->netdev);
365 break;
366
367 case EVENT_BG_SCAN_REPORT:
368 dev_dbg(adapter->dev, "event: BGS_REPORT\n");
fa0ecbb9
BZ
369 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_BG_SCAN_QUERY,
370 HostCmd_ACT_GEN_GET, 0, NULL, false);
5e6e3a92
BZ
371 break;
372
373 case EVENT_PORT_RELEASE:
374 dev_dbg(adapter->dev, "event: PORT RELEASE\n");
375 break;
376
21f58d20
AK
377 case EVENT_EXT_SCAN_REPORT:
378 dev_dbg(adapter->dev, "event: EXT_SCAN Report\n");
379 if (adapter->ext_scan)
380 ret = mwifiex_handle_event_ext_scan_report(priv,
381 adapter->event_skb->data);
382
383 break;
384
5e6e3a92
BZ
385 case EVENT_WMM_STATUS_CHANGE:
386 dev_dbg(adapter->dev, "event: WMM status changed\n");
fa0ecbb9
BZ
387 ret = mwifiex_send_cmd(priv, HostCmd_CMD_WMM_GET_STATUS,
388 0, 0, NULL, false);
5e6e3a92
BZ
389 break;
390
391 case EVENT_RSSI_LOW:
fa444bf8
AK
392 cfg80211_cqm_rssi_notify(priv->netdev,
393 NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
394 GFP_KERNEL);
fa0ecbb9
BZ
395 mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
396 HostCmd_ACT_GEN_GET, 0, NULL, false);
fa444bf8 397 priv->subsc_evt_rssi_state = RSSI_LOW_RECVD;
5e6e3a92
BZ
398 dev_dbg(adapter->dev, "event: Beacon RSSI_LOW\n");
399 break;
400 case EVENT_SNR_LOW:
401 dev_dbg(adapter->dev, "event: Beacon SNR_LOW\n");
402 break;
403 case EVENT_MAX_FAIL:
404 dev_dbg(adapter->dev, "event: MAX_FAIL\n");
405 break;
406 case EVENT_RSSI_HIGH:
fa444bf8
AK
407 cfg80211_cqm_rssi_notify(priv->netdev,
408 NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
409 GFP_KERNEL);
fa0ecbb9
BZ
410 mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
411 HostCmd_ACT_GEN_GET, 0, NULL, false);
fa444bf8 412 priv->subsc_evt_rssi_state = RSSI_HIGH_RECVD;
5e6e3a92
BZ
413 dev_dbg(adapter->dev, "event: Beacon RSSI_HIGH\n");
414 break;
415 case EVENT_SNR_HIGH:
416 dev_dbg(adapter->dev, "event: Beacon SNR_HIGH\n");
417 break;
418 case EVENT_DATA_RSSI_LOW:
419 dev_dbg(adapter->dev, "event: Data RSSI_LOW\n");
420 break;
421 case EVENT_DATA_SNR_LOW:
422 dev_dbg(adapter->dev, "event: Data SNR_LOW\n");
423 break;
424 case EVENT_DATA_RSSI_HIGH:
425 dev_dbg(adapter->dev, "event: Data RSSI_HIGH\n");
426 break;
427 case EVENT_DATA_SNR_HIGH:
428 dev_dbg(adapter->dev, "event: Data SNR_HIGH\n");
429 break;
430 case EVENT_LINK_QUALITY:
431 dev_dbg(adapter->dev, "event: Link Quality\n");
432 break;
433 case EVENT_PRE_BEACON_LOST:
434 dev_dbg(adapter->dev, "event: Pre-Beacon Lost\n");
435 break;
436 case EVENT_IBSS_COALESCED:
437 dev_dbg(adapter->dev, "event: IBSS_COALESCED\n");
fa0ecbb9 438 ret = mwifiex_send_cmd(priv,
5e6e3a92 439 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
fa0ecbb9 440 HostCmd_ACT_GEN_GET, 0, NULL, false);
5e6e3a92
BZ
441 break;
442 case EVENT_ADDBA:
443 dev_dbg(adapter->dev, "event: ADDBA Request\n");
fa0ecbb9
BZ
444 mwifiex_send_cmd(priv, HostCmd_CMD_11N_ADDBA_RSP,
445 HostCmd_ACT_GEN_SET, 0,
446 adapter->event_body, false);
5e6e3a92
BZ
447 break;
448 case EVENT_DELBA:
449 dev_dbg(adapter->dev, "event: DELBA Request\n");
450 mwifiex_11n_delete_ba_stream(priv, adapter->event_body);
451 break;
452 case EVENT_BA_STREAM_TIEMOUT:
453 dev_dbg(adapter->dev, "event: BA Stream timeout\n");
454 mwifiex_11n_ba_stream_timeout(priv,
455 (struct host_cmd_ds_11n_batimeout
456 *)
457 adapter->event_body);
458 break;
459 case EVENT_AMSDU_AGGR_CTRL:
8dd4372e
BZ
460 ctrl = le16_to_cpu(*(__le16 *)adapter->event_body);
461 dev_dbg(adapter->dev, "event: AMSDU_AGGR_CTRL %d\n", ctrl);
462
5e6e3a92 463 adapter->tx_buf_size =
8dd4372e 464 min_t(u16, adapter->curr_tx_buf_size, ctrl);
5e6e3a92 465 dev_dbg(adapter->dev, "event: tx_buf_size %d\n",
500f747c 466 adapter->tx_buf_size);
5e6e3a92
BZ
467 break;
468
469 case EVENT_WEP_ICV_ERR:
470 dev_dbg(adapter->dev, "event: WEP ICV error\n");
471 break;
472
473 case EVENT_BW_CHANGE:
474 dev_dbg(adapter->dev, "event: BW Change\n");
475 break;
476
477 case EVENT_HOSTWAKE_STAIE:
478 dev_dbg(adapter->dev, "event: HOSTWAKE_STAIE %d\n", eventcause);
479 break;
e568634a 480
eab1c76b
SP
481 case EVENT_REMAIN_ON_CHAN_EXPIRED:
482 dev_dbg(adapter->dev, "event: Remain on channel expired\n");
483 cfg80211_remain_on_channel_expired(priv->wdev,
484 priv->roc_cfg.cookie,
485 &priv->roc_cfg.chan,
eab1c76b
SP
486 GFP_ATOMIC);
487
488 memset(&priv->roc_cfg, 0x00, sizeof(struct mwifiex_roc_cfg));
489
490 break;
491
2a7305c8
AK
492 case EVENT_CHANNEL_SWITCH_ANN:
493 dev_dbg(adapter->dev, "event: Channel Switch Announcement\n");
b887664d
AK
494 priv->csa_expire_time =
495 jiffies + msecs_to_jiffies(DFS_CHAN_MOVE_TIME);
496 priv->csa_chan = priv->curr_bss_params.bss_descriptor.channel;
fa0ecbb9 497 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_DEAUTHENTICATE,
2a7305c8 498 HostCmd_ACT_GEN_SET, 0,
fa0ecbb9
BZ
499 priv->curr_bss_params.bss_descriptor.mac_address,
500 false);
2a7305c8
AK
501 break;
502
79ff4346
AP
503 case EVENT_TDLS_GENERIC_EVENT:
504 ret = mwifiex_parse_tdls_event(priv, adapter->event_skb);
505 break;
506
808bbebc
AK
507 case EVENT_TX_STATUS_REPORT:
508 dev_dbg(adapter->dev, "event: TX_STATUS Report\n");
509 mwifiex_parse_tx_status_event(priv, adapter->event_body);
510 break;
511
5e6e3a92
BZ
512 default:
513 dev_dbg(adapter->dev, "event: unknown event id: %#x\n",
500f747c 514 eventcause);
5e6e3a92
BZ
515 break;
516 }
517
518 return ret;
519}
This page took 0.469919 seconds and 5 git commands to generate.