Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: station event handling |
| 3 | * |
Xinming Hu | 65da33f | 2014-06-19 21:38:57 -0700 | [diff] [blame] | 4 | * Copyright (C) 2011-2014, Marvell International Ltd. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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 |
Amitkumar Karwar | 8cc1d52 | 2012-10-05 20:21:43 -0700 | [diff] [blame] | 44 | mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 45 | { |
| 46 | struct mwifiex_adapter *adapter = priv->adapter; |
| 47 | |
| 48 | if (!priv->media_connected) |
| 49 | return; |
| 50 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 51 | mwifiex_dbg(adapter, INFO, |
| 52 | "info: handles disconnect event\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 53 | |
| 54 | priv->media_connected = false; |
| 55 | |
| 56 | priv->scan_block = false; |
Avinash Patil | 5c894633 | 2015-06-22 19:06:18 +0530 | [diff] [blame] | 57 | priv->port_open = false; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 58 | |
Avinash Patil | be104b9 | 2014-02-07 16:30:41 -0800 | [diff] [blame] | 59 | if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) && |
Avinash Patil | 9927baa | 2014-11-13 21:54:16 +0530 | [diff] [blame] | 60 | ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info)) { |
Avinash Patil | be104b9 | 2014-02-07 16:30:41 -0800 | [diff] [blame] | 61 | mwifiex_disable_all_tdls_links(priv); |
| 62 | |
Avinash Patil | 9927baa | 2014-11-13 21:54:16 +0530 | [diff] [blame] | 63 | if (priv->adapter->auto_tdls) |
| 64 | mwifiex_clean_auto_tdls(priv); |
| 65 | } |
| 66 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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 | |
Yogesh Ashok Powar | 2be50b8 | 2011-04-01 18:36:47 -0700 | [diff] [blame] | 89 | priv->sec_info.encryption_mode = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 90 | |
| 91 | /* Enable auto data rate */ |
| 92 | priv->is_data_rate_auto = true; |
| 93 | priv->data_rate = 0; |
| 94 | |
Xinming Hu | cbf6e05 | 2014-12-23 19:14:07 +0530 | [diff] [blame] | 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 | |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 99 | if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 109 | mwifiex_dbg(adapter, INFO, |
| 110 | "info: previous SSID=%s, SSID len=%u\n", |
| 111 | priv->prev_ssid.ssid, priv->prev_ssid.ssid_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 112 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 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); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 117 | |
| 118 | memcpy(&priv->prev_ssid, |
| 119 | &priv->curr_bss_params.bss_descriptor.ssid, |
Amitkumar Karwar | b9be5f3 | 2012-02-27 22:04:14 -0800 | [diff] [blame] | 120 | sizeof(struct cfg80211_ssid)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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 | |
Amitkumar Karwar | 0c9c4a0 | 2014-02-27 19:35:17 -0800 | [diff] [blame] | 131 | if (adapter->is_cmd_timedout && adapter->curr_cmd) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 132 | return; |
| 133 | priv->media_connected = false; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 134 | mwifiex_dbg(adapter, MSG, |
| 135 | "info: successfully disconnected from %pM: reason code %d\n", |
| 136 | priv->cfg_bssid, reason_code); |
Avinash Patil | 9612bd1 | 2013-10-11 18:31:32 -0700 | [diff] [blame] | 137 | if (priv->bss_mode == NL80211_IFTYPE_STATION || |
| 138 | priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) { |
Amitkumar Karwar | 8cc1d52 | 2012-10-05 20:21:43 -0700 | [diff] [blame] | 139 | cfg80211_disconnected(priv->netdev, reason_code, NULL, 0, |
Johannes Berg | 80279fb | 2015-05-22 16:22:20 +0200 | [diff] [blame] | 140 | false, GFP_KERNEL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 141 | } |
Joe Perches | 93803b3 | 2015-03-02 19:54:49 -0800 | [diff] [blame] | 142 | eth_zero_addr(priv->cfg_bssid); |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 143 | |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 144 | mwifiex_stop_net_dev_queue(priv->netdev, adapter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 145 | if (netif_carrier_ok(priv->netdev)) |
| 146 | netif_carrier_off(priv->netdev); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Avinash Patil | 79ff434 | 2014-05-06 22:02:44 -0700 | [diff] [blame] | 149 | static int mwifiex_parse_tdls_event(struct mwifiex_private *priv, |
| 150 | struct sk_buff *event_skb) |
| 151 | { |
Avinash Patil | c1078bc | 2014-05-21 22:02:29 -0700 | [diff] [blame] | 152 | int ret = 0; |
Avinash Patil | 79ff434 | 2014-05-06 22:02:44 -0700 | [diff] [blame] | 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); |
Xinming Hu | f766987 | 2015-06-22 19:06:11 +0530 | [diff] [blame] | 157 | u8 *mac = tdls_evt->peer_mac; |
Avinash Patil | 79ff434 | 2014-05-06 22:02:44 -0700 | [diff] [blame] | 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))) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 162 | mwifiex_dbg(adapter, ERROR, "Invalid event length!\n"); |
Avinash Patil | 79ff434 | 2014-05-06 22:02:44 -0700 | [diff] [blame] | 163 | return -1; |
| 164 | } |
| 165 | |
| 166 | sta_ptr = mwifiex_get_sta_entry(priv, tdls_evt->peer_mac); |
| 167 | if (!sta_ptr) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 168 | mwifiex_dbg(adapter, ERROR, "cannot get sta entry!\n"); |
Avinash Patil | 79ff434 | 2014-05-06 22:02:44 -0700 | [diff] [blame] | 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; |
Xinming Hu | f766987 | 2015-06-22 19:06:11 +0530 | [diff] [blame] | 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; |
Avinash Patil | 79ff434 | 2014-05-06 22:02:44 -0700 | [diff] [blame] | 233 | default: |
| 234 | break; |
| 235 | } |
| 236 | |
Avinash Patil | c1078bc | 2014-05-21 22:02:29 -0700 | [diff] [blame] | 237 | return ret; |
Avinash Patil | 79ff434 | 2014-05-06 22:02:44 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 240 | static void mwifiex_process_uap_tx_pause(struct mwifiex_private *priv, |
| 241 | struct mwifiex_ie_types_header *tlv) |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 242 | { |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 243 | struct mwifiex_tx_pause_tlv *tp; |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 244 | struct mwifiex_sta_node *sta_ptr; |
| 245 | unsigned long flags; |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 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 | |
| 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 | |
Avinash Patil | 8d6b538 | 2015-06-22 19:06:23 +0530 | [diff] [blame] | 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 | u16 status; |
| 317 | |
| 318 | chan_info = (void *)event_skb->data + sizeof(u32); |
| 319 | |
| 320 | if (le16_to_cpu(chan_info->header.type) != TLV_TYPE_MULTI_CHAN_INFO) { |
| 321 | mwifiex_dbg(priv->adapter, ERROR, |
| 322 | "unknown TLV in chan_info event\n"); |
| 323 | return; |
| 324 | } |
| 325 | |
| 326 | status = le16_to_cpu(chan_info->status); |
| 327 | |
| 328 | if (status) { |
| 329 | mwifiex_dbg(priv->adapter, EVENT, |
| 330 | "multi-channel operation started\n"); |
| 331 | } else { |
| 332 | mwifiex_dbg(priv->adapter, EVENT, |
| 333 | "multi-channel operation over\n"); |
| 334 | } |
| 335 | } |
| 336 | |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 337 | void mwifiex_process_tx_pause_event(struct mwifiex_private *priv, |
| 338 | struct sk_buff *event_skb) |
| 339 | { |
| 340 | struct mwifiex_ie_types_header *tlv; |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 341 | u16 tlv_type, tlv_len; |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 342 | int tlv_buf_left; |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 343 | |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 344 | if (!priv->media_connected) { |
| 345 | mwifiex_dbg(priv->adapter, ERROR, |
| 346 | "tx_pause event while disconnected; bss_role=%d\n", |
| 347 | priv->bss_role); |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 348 | return; |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 349 | } |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 350 | |
| 351 | tlv_buf_left = event_skb->len - sizeof(u32); |
| 352 | tlv = (void *)event_skb->data + sizeof(u32); |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 353 | |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 354 | while (tlv_buf_left >= (int)sizeof(struct mwifiex_ie_types_header)) { |
| 355 | tlv_type = le16_to_cpu(tlv->type); |
| 356 | tlv_len = le16_to_cpu(tlv->len); |
| 357 | if ((sizeof(struct mwifiex_ie_types_header) + tlv_len) > |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 358 | tlv_buf_left) { |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 359 | mwifiex_dbg(priv->adapter, ERROR, |
| 360 | "wrong tlv: tlvLen=%d, tlvBufLeft=%d\n", |
| 361 | tlv_len, tlv_buf_left); |
| 362 | break; |
| 363 | } |
| 364 | if (tlv_type == TLV_TYPE_TX_PAUSE) { |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 365 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) |
| 366 | mwifiex_process_sta_tx_pause(priv, tlv); |
| 367 | else |
| 368 | mwifiex_process_uap_tx_pause(priv, tlv); |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | tlv_buf_left -= sizeof(struct mwifiex_ie_types_header) + |
| 372 | tlv_len; |
| 373 | tlv = (void *)((u8 *)tlv + tlv_len + |
| 374 | sizeof(struct mwifiex_ie_types_header)); |
| 375 | } |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 376 | |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 377 | } |
| 378 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 379 | /* |
Chunfan Chen | d219b7e | 2015-06-10 06:19:48 -0700 | [diff] [blame] | 380 | * This function handles coex events generated by firmware |
| 381 | */ |
| 382 | void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv, |
| 383 | struct sk_buff *event_skb) |
| 384 | { |
| 385 | struct mwifiex_adapter *adapter = priv->adapter; |
| 386 | struct mwifiex_ie_types_header *tlv; |
| 387 | struct mwifiex_ie_types_btcoex_aggr_win_size *winsizetlv; |
| 388 | struct mwifiex_ie_types_btcoex_scan_time *scantlv; |
| 389 | s32 len = event_skb->len - sizeof(u32); |
| 390 | u8 *cur_ptr = event_skb->data + sizeof(u32); |
| 391 | u16 tlv_type, tlv_len; |
| 392 | |
| 393 | while (len >= sizeof(struct mwifiex_ie_types_header)) { |
| 394 | tlv = (struct mwifiex_ie_types_header *)cur_ptr; |
| 395 | tlv_len = le16_to_cpu(tlv->len); |
| 396 | tlv_type = le16_to_cpu(tlv->type); |
| 397 | |
| 398 | if ((tlv_len + sizeof(struct mwifiex_ie_types_header)) > len) |
| 399 | break; |
| 400 | switch (tlv_type) { |
| 401 | case TLV_BTCOEX_WL_AGGR_WINSIZE: |
| 402 | winsizetlv = |
| 403 | (struct mwifiex_ie_types_btcoex_aggr_win_size *)tlv; |
| 404 | adapter->coex_win_size = winsizetlv->coex_win_size; |
| 405 | adapter->coex_tx_win_size = |
| 406 | winsizetlv->tx_win_size; |
| 407 | adapter->coex_rx_win_size = |
| 408 | winsizetlv->rx_win_size; |
| 409 | mwifiex_coex_ampdu_rxwinsize(adapter); |
| 410 | mwifiex_update_ampdu_txwinsize(adapter); |
| 411 | break; |
| 412 | |
| 413 | case TLV_BTCOEX_WL_SCANTIME: |
| 414 | scantlv = |
| 415 | (struct mwifiex_ie_types_btcoex_scan_time *)tlv; |
| 416 | adapter->coex_scan = scantlv->coex_scan; |
| 417 | adapter->coex_min_scan_time = scantlv->min_scan_time; |
| 418 | adapter->coex_max_scan_time = scantlv->max_scan_time; |
| 419 | break; |
| 420 | |
| 421 | default: |
| 422 | break; |
| 423 | } |
| 424 | |
| 425 | len -= tlv_len + sizeof(struct mwifiex_ie_types_header); |
| 426 | cur_ptr += tlv_len + |
| 427 | sizeof(struct mwifiex_ie_types_header); |
| 428 | } |
| 429 | |
| 430 | dev_dbg(adapter->dev, "coex_scan=%d min_scan=%d coex_win=%d, tx_win=%d rx_win=%d\n", |
| 431 | adapter->coex_scan, adapter->coex_min_scan_time, |
| 432 | adapter->coex_win_size, adapter->coex_tx_win_size, |
| 433 | adapter->coex_rx_win_size); |
| 434 | } |
| 435 | |
| 436 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 437 | * This function handles events generated by firmware. |
| 438 | * |
| 439 | * This is a generic function and handles all events. |
| 440 | * |
| 441 | * Event specific routines are called by this function based |
| 442 | * upon the generated event cause. |
| 443 | * |
| 444 | * For the following events, the function just forwards them to upper |
| 445 | * layers, optionally recording the change - |
| 446 | * - EVENT_LINK_SENSED |
| 447 | * - EVENT_MIC_ERR_UNICAST |
| 448 | * - EVENT_MIC_ERR_MULTICAST |
| 449 | * - EVENT_PORT_RELEASE |
| 450 | * - EVENT_RSSI_LOW |
| 451 | * - EVENT_SNR_LOW |
| 452 | * - EVENT_MAX_FAIL |
| 453 | * - EVENT_RSSI_HIGH |
| 454 | * - EVENT_SNR_HIGH |
| 455 | * - EVENT_DATA_RSSI_LOW |
| 456 | * - EVENT_DATA_SNR_LOW |
| 457 | * - EVENT_DATA_RSSI_HIGH |
| 458 | * - EVENT_DATA_SNR_HIGH |
| 459 | * - EVENT_LINK_QUALITY |
| 460 | * - EVENT_PRE_BEACON_LOST |
| 461 | * - EVENT_IBSS_COALESCED |
| 462 | * - EVENT_WEP_ICV_ERR |
| 463 | * - EVENT_BW_CHANGE |
| 464 | * - EVENT_HOSTWAKE_STAIE |
| 465 | * |
| 466 | * For the following events, no action is taken - |
| 467 | * - EVENT_MIB_CHANGED |
| 468 | * - EVENT_INIT_DONE |
| 469 | * - EVENT_DUMMY_HOST_WAKEUP_SIGNAL |
| 470 | * |
| 471 | * Rest of the supported events requires driver handling - |
| 472 | * - EVENT_DEAUTHENTICATED |
| 473 | * - EVENT_DISASSOCIATED |
| 474 | * - EVENT_LINK_LOST |
| 475 | * - EVENT_PS_SLEEP |
| 476 | * - EVENT_PS_AWAKE |
| 477 | * - EVENT_DEEP_SLEEP_AWAKE |
| 478 | * - EVENT_HS_ACT_REQ |
| 479 | * - EVENT_ADHOC_BCN_LOST |
| 480 | * - EVENT_BG_SCAN_REPORT |
| 481 | * - EVENT_WMM_STATUS_CHANGE |
| 482 | * - EVENT_ADDBA |
| 483 | * - EVENT_DELBA |
| 484 | * - EVENT_BA_STREAM_TIEMOUT |
| 485 | * - EVENT_AMSDU_AGGR_CTRL |
| 486 | */ |
| 487 | int mwifiex_process_sta_event(struct mwifiex_private *priv) |
| 488 | { |
| 489 | struct mwifiex_adapter *adapter = priv->adapter; |
Avinash Patil | 3d99d98 | 2012-08-03 18:06:06 -0700 | [diff] [blame] | 490 | int ret = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 491 | u32 eventcause = adapter->event_cause; |
Amitkumar Karwar | 8cc1d52 | 2012-10-05 20:21:43 -0700 | [diff] [blame] | 492 | u16 ctrl, reason_code; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 493 | |
| 494 | switch (eventcause) { |
| 495 | case EVENT_DUMMY_HOST_WAKEUP_SIGNAL: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 496 | mwifiex_dbg(adapter, ERROR, |
| 497 | "invalid EVENT: DUMMY_HOST_WAKEUP_SIGNAL, ignore it\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 498 | break; |
| 499 | case EVENT_LINK_SENSED: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 500 | mwifiex_dbg(adapter, EVENT, "event: LINK_SENSED\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 501 | if (!netif_carrier_ok(priv->netdev)) |
| 502 | netif_carrier_on(priv->netdev); |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 503 | mwifiex_wake_up_net_dev_queue(priv->netdev, adapter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 504 | break; |
| 505 | |
| 506 | case EVENT_DEAUTHENTICATED: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 507 | mwifiex_dbg(adapter, EVENT, "event: Deauthenticated\n"); |
Stone Piao | eaf49db | 2013-07-22 19:17:43 -0700 | [diff] [blame] | 508 | if (priv->wps.session_enable) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 509 | mwifiex_dbg(adapter, INFO, |
| 510 | "info: receive deauth event in wps session\n"); |
Stone Piao | eaf49db | 2013-07-22 19:17:43 -0700 | [diff] [blame] | 511 | break; |
| 512 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 513 | adapter->dbg.num_event_deauth++; |
Amitkumar Karwar | 8cc1d52 | 2012-10-05 20:21:43 -0700 | [diff] [blame] | 514 | if (priv->media_connected) { |
| 515 | reason_code = |
| 516 | le16_to_cpu(*(__le16 *)adapter->event_body); |
| 517 | mwifiex_reset_connect_state(priv, reason_code); |
| 518 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 519 | break; |
| 520 | |
| 521 | case EVENT_DISASSOCIATED: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 522 | mwifiex_dbg(adapter, EVENT, "event: Disassociated\n"); |
Stone Piao | eaf49db | 2013-07-22 19:17:43 -0700 | [diff] [blame] | 523 | if (priv->wps.session_enable) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 524 | mwifiex_dbg(adapter, INFO, |
| 525 | "info: receive disassoc event in wps session\n"); |
Stone Piao | eaf49db | 2013-07-22 19:17:43 -0700 | [diff] [blame] | 526 | break; |
| 527 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 528 | adapter->dbg.num_event_disassoc++; |
Amitkumar Karwar | 8cc1d52 | 2012-10-05 20:21:43 -0700 | [diff] [blame] | 529 | if (priv->media_connected) { |
| 530 | reason_code = |
| 531 | le16_to_cpu(*(__le16 *)adapter->event_body); |
| 532 | mwifiex_reset_connect_state(priv, reason_code); |
| 533 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 534 | break; |
| 535 | |
| 536 | case EVENT_LINK_LOST: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 537 | mwifiex_dbg(adapter, EVENT, "event: Link lost\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 538 | adapter->dbg.num_event_link_lost++; |
Amitkumar Karwar | 8cc1d52 | 2012-10-05 20:21:43 -0700 | [diff] [blame] | 539 | if (priv->media_connected) { |
| 540 | reason_code = |
| 541 | le16_to_cpu(*(__le16 *)adapter->event_body); |
| 542 | mwifiex_reset_connect_state(priv, reason_code); |
| 543 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 544 | break; |
| 545 | |
| 546 | case EVENT_PS_SLEEP: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 547 | mwifiex_dbg(adapter, EVENT, "info: EVENT: SLEEP\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 548 | |
| 549 | adapter->ps_state = PS_STATE_PRE_SLEEP; |
| 550 | |
| 551 | mwifiex_check_ps_cond(adapter); |
| 552 | break; |
| 553 | |
| 554 | case EVENT_PS_AWAKE: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 555 | mwifiex_dbg(adapter, EVENT, "info: EVENT: AWAKE\n"); |
Avinash Patil | 5c894633 | 2015-06-22 19:06:18 +0530 | [diff] [blame] | 556 | if (!adapter->pps_uapsd_mode && priv->port_open && |
Yogesh Ashok Powar | 500f747 | 2012-03-13 19:22:41 -0700 | [diff] [blame] | 557 | priv->media_connected && adapter->sleep_period.period) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 558 | adapter->pps_uapsd_mode = true; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 559 | mwifiex_dbg(adapter, EVENT, |
| 560 | "event: PPS/UAPSD mode activated\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 561 | } |
| 562 | adapter->tx_lock_flag = false; |
| 563 | if (adapter->pps_uapsd_mode && adapter->gen_null_pkt) { |
| 564 | if (mwifiex_check_last_packet_indication(priv)) { |
Yogesh Ashok Powar | 500f747 | 2012-03-13 19:22:41 -0700 | [diff] [blame] | 565 | if (adapter->data_sent) { |
| 566 | adapter->ps_state = PS_STATE_AWAKE; |
| 567 | adapter->pm_wakeup_card_req = false; |
| 568 | adapter->pm_wakeup_fw_try = false; |
Amitkumar Karwar | 6e9344f | 2015-03-12 00:38:40 -0700 | [diff] [blame] | 569 | del_timer(&adapter->wakeup_timer); |
Yogesh Ashok Powar | 500f747 | 2012-03-13 19:22:41 -0700 | [diff] [blame] | 570 | break; |
| 571 | } |
| 572 | if (!mwifiex_send_null_packet |
| 573 | (priv, |
| 574 | MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET | |
| 575 | MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET)) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 576 | adapter->ps_state = |
| 577 | PS_STATE_SLEEP; |
| 578 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 579 | } |
| 580 | } |
| 581 | adapter->ps_state = PS_STATE_AWAKE; |
| 582 | adapter->pm_wakeup_card_req = false; |
| 583 | adapter->pm_wakeup_fw_try = false; |
Amitkumar Karwar | 6e9344f | 2015-03-12 00:38:40 -0700 | [diff] [blame] | 584 | del_timer(&adapter->wakeup_timer); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 585 | |
| 586 | break; |
| 587 | |
| 588 | case EVENT_DEEP_SLEEP_AWAKE: |
| 589 | adapter->if_ops.wakeup_complete(adapter); |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 590 | mwifiex_dbg(adapter, EVENT, "event: DS_AWAKE\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 591 | if (adapter->is_deep_sleep) |
| 592 | adapter->is_deep_sleep = false; |
| 593 | break; |
| 594 | |
| 595 | case EVENT_HS_ACT_REQ: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 596 | mwifiex_dbg(adapter, EVENT, "event: HS_ACT_REQ\n"); |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 597 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_HS_CFG_ENH, |
| 598 | 0, 0, NULL, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 599 | break; |
| 600 | |
| 601 | case EVENT_MIC_ERR_UNICAST: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 602 | mwifiex_dbg(adapter, EVENT, "event: UNICAST MIC ERROR\n"); |
Amitkumar Karwar | 9c7ff73 | 2012-08-08 19:02:56 -0700 | [diff] [blame] | 603 | cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid, |
| 604 | NL80211_KEYTYPE_PAIRWISE, |
| 605 | -1, NULL, GFP_KERNEL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 606 | break; |
| 607 | |
| 608 | case EVENT_MIC_ERR_MULTICAST: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 609 | mwifiex_dbg(adapter, EVENT, "event: MULTICAST MIC ERROR\n"); |
Amitkumar Karwar | 9c7ff73 | 2012-08-08 19:02:56 -0700 | [diff] [blame] | 610 | cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid, |
| 611 | NL80211_KEYTYPE_GROUP, |
| 612 | -1, NULL, GFP_KERNEL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 613 | break; |
| 614 | case EVENT_MIB_CHANGED: |
| 615 | case EVENT_INIT_DONE: |
| 616 | break; |
| 617 | |
| 618 | case EVENT_ADHOC_BCN_LOST: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 619 | mwifiex_dbg(adapter, EVENT, "event: ADHOC_BCN_LOST\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 620 | priv->adhoc_is_link_sensed = false; |
| 621 | mwifiex_clean_txrx(priv); |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 622 | mwifiex_stop_net_dev_queue(priv->netdev, adapter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 623 | if (netif_carrier_ok(priv->netdev)) |
| 624 | netif_carrier_off(priv->netdev); |
| 625 | break; |
| 626 | |
| 627 | case EVENT_BG_SCAN_REPORT: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 628 | mwifiex_dbg(adapter, EVENT, "event: BGS_REPORT\n"); |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 629 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_BG_SCAN_QUERY, |
| 630 | HostCmd_ACT_GEN_GET, 0, NULL, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 631 | break; |
| 632 | |
| 633 | case EVENT_PORT_RELEASE: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 634 | mwifiex_dbg(adapter, EVENT, "event: PORT RELEASE\n"); |
Avinash Patil | 5c894633 | 2015-06-22 19:06:18 +0530 | [diff] [blame] | 635 | priv->port_open = true; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 636 | break; |
| 637 | |
Amitkumar Karwar | 21f58d20 | 2014-02-11 18:39:56 -0800 | [diff] [blame] | 638 | case EVENT_EXT_SCAN_REPORT: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 639 | mwifiex_dbg(adapter, EVENT, "event: EXT_SCAN Report\n"); |
Amitkumar Karwar | 21f58d20 | 2014-02-11 18:39:56 -0800 | [diff] [blame] | 640 | if (adapter->ext_scan) |
| 641 | ret = mwifiex_handle_event_ext_scan_report(priv, |
| 642 | adapter->event_skb->data); |
| 643 | |
| 644 | break; |
| 645 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 646 | case EVENT_WMM_STATUS_CHANGE: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 647 | mwifiex_dbg(adapter, EVENT, "event: WMM status changed\n"); |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 648 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_WMM_GET_STATUS, |
| 649 | 0, 0, NULL, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 650 | break; |
| 651 | |
| 652 | case EVENT_RSSI_LOW: |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 653 | cfg80211_cqm_rssi_notify(priv->netdev, |
| 654 | NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW, |
| 655 | GFP_KERNEL); |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 656 | mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO, |
| 657 | HostCmd_ACT_GEN_GET, 0, NULL, false); |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 658 | priv->subsc_evt_rssi_state = RSSI_LOW_RECVD; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 659 | mwifiex_dbg(adapter, EVENT, "event: Beacon RSSI_LOW\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 660 | break; |
| 661 | case EVENT_SNR_LOW: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 662 | mwifiex_dbg(adapter, EVENT, "event: Beacon SNR_LOW\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 663 | break; |
| 664 | case EVENT_MAX_FAIL: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 665 | mwifiex_dbg(adapter, EVENT, "event: MAX_FAIL\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 666 | break; |
| 667 | case EVENT_RSSI_HIGH: |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 668 | cfg80211_cqm_rssi_notify(priv->netdev, |
| 669 | NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH, |
| 670 | GFP_KERNEL); |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 671 | mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO, |
| 672 | HostCmd_ACT_GEN_GET, 0, NULL, false); |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 673 | priv->subsc_evt_rssi_state = RSSI_HIGH_RECVD; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 674 | mwifiex_dbg(adapter, EVENT, "event: Beacon RSSI_HIGH\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 675 | break; |
| 676 | case EVENT_SNR_HIGH: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 677 | mwifiex_dbg(adapter, EVENT, "event: Beacon SNR_HIGH\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 678 | break; |
| 679 | case EVENT_DATA_RSSI_LOW: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 680 | mwifiex_dbg(adapter, EVENT, "event: Data RSSI_LOW\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 681 | break; |
| 682 | case EVENT_DATA_SNR_LOW: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 683 | mwifiex_dbg(adapter, EVENT, "event: Data SNR_LOW\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 684 | break; |
| 685 | case EVENT_DATA_RSSI_HIGH: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 686 | mwifiex_dbg(adapter, EVENT, "event: Data RSSI_HIGH\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 687 | break; |
| 688 | case EVENT_DATA_SNR_HIGH: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 689 | mwifiex_dbg(adapter, EVENT, "event: Data SNR_HIGH\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 690 | break; |
| 691 | case EVENT_LINK_QUALITY: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 692 | mwifiex_dbg(adapter, EVENT, "event: Link Quality\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 693 | break; |
| 694 | case EVENT_PRE_BEACON_LOST: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 695 | mwifiex_dbg(adapter, EVENT, "event: Pre-Beacon Lost\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 696 | break; |
| 697 | case EVENT_IBSS_COALESCED: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 698 | mwifiex_dbg(adapter, EVENT, "event: IBSS_COALESCED\n"); |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 699 | ret = mwifiex_send_cmd(priv, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 700 | HostCmd_CMD_802_11_IBSS_COALESCING_STATUS, |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 701 | HostCmd_ACT_GEN_GET, 0, NULL, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 702 | break; |
| 703 | case EVENT_ADDBA: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 704 | mwifiex_dbg(adapter, EVENT, "event: ADDBA Request\n"); |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 705 | mwifiex_send_cmd(priv, HostCmd_CMD_11N_ADDBA_RSP, |
| 706 | HostCmd_ACT_GEN_SET, 0, |
| 707 | adapter->event_body, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 708 | break; |
| 709 | case EVENT_DELBA: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 710 | mwifiex_dbg(adapter, EVENT, "event: DELBA Request\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 711 | mwifiex_11n_delete_ba_stream(priv, adapter->event_body); |
| 712 | break; |
| 713 | case EVENT_BA_STREAM_TIEMOUT: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 714 | mwifiex_dbg(adapter, EVENT, "event: BA Stream timeout\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 715 | mwifiex_11n_ba_stream_timeout(priv, |
| 716 | (struct host_cmd_ds_11n_batimeout |
| 717 | *) |
| 718 | adapter->event_body); |
| 719 | break; |
| 720 | case EVENT_AMSDU_AGGR_CTRL: |
Bing Zhao | 8dd4372 | 2012-08-07 16:08:08 -0700 | [diff] [blame] | 721 | ctrl = le16_to_cpu(*(__le16 *)adapter->event_body); |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 722 | mwifiex_dbg(adapter, EVENT, |
| 723 | "event: AMSDU_AGGR_CTRL %d\n", ctrl); |
Bing Zhao | 8dd4372 | 2012-08-07 16:08:08 -0700 | [diff] [blame] | 724 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 725 | adapter->tx_buf_size = |
Bing Zhao | 8dd4372 | 2012-08-07 16:08:08 -0700 | [diff] [blame] | 726 | min_t(u16, adapter->curr_tx_buf_size, ctrl); |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 727 | mwifiex_dbg(adapter, EVENT, "event: tx_buf_size %d\n", |
| 728 | adapter->tx_buf_size); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 729 | break; |
| 730 | |
| 731 | case EVENT_WEP_ICV_ERR: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 732 | mwifiex_dbg(adapter, EVENT, "event: WEP ICV error\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 733 | break; |
| 734 | |
| 735 | case EVENT_BW_CHANGE: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 736 | mwifiex_dbg(adapter, EVENT, "event: BW Change\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 737 | break; |
| 738 | |
| 739 | case EVENT_HOSTWAKE_STAIE: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 740 | mwifiex_dbg(adapter, EVENT, |
| 741 | "event: HOSTWAKE_STAIE %d\n", eventcause); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 742 | break; |
Avinash Patil | e568634 | 2012-05-08 18:30:25 -0700 | [diff] [blame] | 743 | |
Stone Piao | eab1c76 | 2012-09-25 20:23:37 -0700 | [diff] [blame] | 744 | case EVENT_REMAIN_ON_CHAN_EXPIRED: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 745 | mwifiex_dbg(adapter, EVENT, |
| 746 | "event: Remain on channel expired\n"); |
Avinash Patil | 4facc34 | 2015-01-28 15:42:00 +0530 | [diff] [blame] | 747 | cfg80211_remain_on_channel_expired(&priv->wdev, |
Stone Piao | eab1c76 | 2012-09-25 20:23:37 -0700 | [diff] [blame] | 748 | priv->roc_cfg.cookie, |
| 749 | &priv->roc_cfg.chan, |
Stone Piao | eab1c76 | 2012-09-25 20:23:37 -0700 | [diff] [blame] | 750 | GFP_ATOMIC); |
| 751 | |
| 752 | memset(&priv->roc_cfg, 0x00, sizeof(struct mwifiex_roc_cfg)); |
| 753 | |
| 754 | break; |
| 755 | |
Amitkumar Karwar | 2a7305c | 2013-06-19 08:49:05 -0700 | [diff] [blame] | 756 | case EVENT_CHANNEL_SWITCH_ANN: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 757 | mwifiex_dbg(adapter, EVENT, "event: Channel Switch Announcement\n"); |
Amitkumar Karwar | b887664 | 2013-06-18 16:36:58 -0700 | [diff] [blame] | 758 | priv->csa_expire_time = |
| 759 | jiffies + msecs_to_jiffies(DFS_CHAN_MOVE_TIME); |
| 760 | priv->csa_chan = priv->curr_bss_params.bss_descriptor.channel; |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 761 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_DEAUTHENTICATE, |
Amitkumar Karwar | 2a7305c | 2013-06-19 08:49:05 -0700 | [diff] [blame] | 762 | HostCmd_ACT_GEN_SET, 0, |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 763 | priv->curr_bss_params.bss_descriptor.mac_address, |
| 764 | false); |
Amitkumar Karwar | 2a7305c | 2013-06-19 08:49:05 -0700 | [diff] [blame] | 765 | break; |
| 766 | |
Avinash Patil | 79ff434 | 2014-05-06 22:02:44 -0700 | [diff] [blame] | 767 | case EVENT_TDLS_GENERIC_EVENT: |
| 768 | ret = mwifiex_parse_tdls_event(priv, adapter->event_skb); |
| 769 | break; |
| 770 | |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 771 | case EVENT_TX_DATA_PAUSE: |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 772 | mwifiex_dbg(adapter, EVENT, "event: TX DATA PAUSE\n"); |
Avinash Patil | ddd7ceb | 2015-06-22 19:06:19 +0530 | [diff] [blame] | 773 | mwifiex_process_tx_pause_event(priv, adapter->event_skb); |
Avinash Patil | 4e6ee91 | 2015-06-22 19:06:07 +0530 | [diff] [blame] | 774 | break; |
| 775 | |
Avinash Patil | 8d6b538 | 2015-06-22 19:06:23 +0530 | [diff] [blame] | 776 | case EVENT_MULTI_CHAN_INFO: |
| 777 | mwifiex_dbg(adapter, EVENT, "event: multi-chan info\n"); |
| 778 | mwifiex_process_multi_chan_event(priv, adapter->event_skb); |
| 779 | break; |
| 780 | |
Amitkumar Karwar | 808bbeb | 2014-11-25 06:43:05 -0800 | [diff] [blame] | 781 | case EVENT_TX_STATUS_REPORT: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 782 | mwifiex_dbg(adapter, EVENT, "event: TX_STATUS Report\n"); |
Amitkumar Karwar | 808bbeb | 2014-11-25 06:43:05 -0800 | [diff] [blame] | 783 | mwifiex_parse_tx_status_event(priv, adapter->event_body); |
| 784 | break; |
| 785 | |
Avinash Patil | 0a694d6 | 2015-01-28 15:54:22 +0530 | [diff] [blame] | 786 | case EVENT_CHANNEL_REPORT_RDY: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 787 | mwifiex_dbg(adapter, EVENT, "event: Channel Report\n"); |
Avinash Patil | 0a694d6 | 2015-01-28 15:54:22 +0530 | [diff] [blame] | 788 | ret = mwifiex_11h_handle_chanrpt_ready(priv, |
| 789 | adapter->event_skb); |
| 790 | break; |
Avinash Patil | 3b57c1a | 2015-01-28 15:54:23 +0530 | [diff] [blame] | 791 | case EVENT_RADAR_DETECTED: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 792 | mwifiex_dbg(adapter, EVENT, "event: Radar detected\n"); |
Avinash Patil | 3b57c1a | 2015-01-28 15:54:23 +0530 | [diff] [blame] | 793 | ret = mwifiex_11h_handle_radar_detected(priv, |
| 794 | adapter->event_skb); |
| 795 | break; |
Chunfan Chen | d219b7e | 2015-06-10 06:19:48 -0700 | [diff] [blame] | 796 | case EVENT_BT_COEX_WLAN_PARA_CHANGE: |
| 797 | dev_dbg(adapter->dev, "EVENT: BT coex wlan param update\n"); |
| 798 | mwifiex_bt_coex_wlan_param_update_event(priv, |
| 799 | adapter->event_skb); |
Amitkumar Karwar | 323d8f1 | 2015-06-15 04:03:35 -0700 | [diff] [blame] | 800 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 801 | default: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 802 | mwifiex_dbg(adapter, ERROR, "event: unknown event id: %#x\n", |
| 803 | eventcause); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 804 | break; |
| 805 | } |
| 806 | |
| 807 | return ret; |
| 808 | } |