Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of version 2 of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | ******************************************************************************/ |
| 15 | #define _RTW_MLME_C_ |
| 16 | |
| 17 | #include <osdep_service.h> |
| 18 | #include <drv_types.h> |
| 19 | #include <recv_osdep.h> |
| 20 | #include <xmit_osdep.h> |
| 21 | #include <hal_intf.h> |
| 22 | #include <mlme_osdep.h> |
| 23 | #include <sta_info.h> |
| 24 | #include <linux/ieee80211.h> |
| 25 | #include <wifi.h> |
| 26 | #include <wlan_bssdef.h> |
Jes Sorensen | b7c19c2 | 2014-05-16 10:04:00 +0200 | [diff] [blame] | 27 | #include <rtw_sreset.h> |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 28 | |
Jes Sorensen | 0e634a0 | 2014-06-09 15:16:49 +0200 | [diff] [blame] | 29 | static struct wlan_network * |
| 30 | rtw_select_candidate_from_queue(struct mlme_priv *pmlmepriv); |
Jes Sorensen | e007b4c | 2014-06-09 15:17:00 +0200 | [diff] [blame] | 31 | static int rtw_do_join(struct rtw_adapter *padapter); |
Jes Sorensen | 0e634a0 | 2014-06-09 15:16:49 +0200 | [diff] [blame] | 32 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 33 | static void rtw_init_mlme_timer(struct rtw_adapter *padapter) |
| 34 | { |
Jes Sorensen | 8b3d9cd | 2014-05-31 18:05:09 +0200 | [diff] [blame] | 35 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 36 | |
| 37 | setup_timer(&pmlmepriv->assoc_timer, rtw23a_join_to_handler, |
| 38 | (unsigned long)padapter); |
| 39 | |
| 40 | setup_timer(&pmlmepriv->scan_to_timer, rtw_scan_timeout_handler23a, |
| 41 | (unsigned long)padapter); |
| 42 | |
| 43 | setup_timer(&pmlmepriv->dynamic_chk_timer, |
| 44 | rtw_dynamic_check_timer_handler, (unsigned long)padapter); |
| 45 | |
| 46 | setup_timer(&pmlmepriv->set_scan_deny_timer, |
| 47 | rtw_set_scan_deny_timer_hdl, (unsigned long)padapter); |
| 48 | } |
| 49 | |
Jes Sorensen | a7efff2 | 2014-04-26 18:55:46 +0200 | [diff] [blame] | 50 | int rtw_init_mlme_priv23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 51 | { |
| 52 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 53 | |
| 54 | pmlmepriv->nic_hdl = padapter; |
| 55 | |
| 56 | pmlmepriv->fw_state = 0; |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 57 | pmlmepriv->cur_network.network.ifmode = NL80211_IFTYPE_UNSPECIFIED; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 58 | /* 1: active, 0: pasive. Maybe someday we should rename this |
| 59 | varable to "active_mode" (Jeff) */ |
| 60 | pmlmepriv->scan_mode = SCAN_ACTIVE; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 61 | |
| 62 | spin_lock_init(&pmlmepriv->lock); |
| 63 | _rtw_init_queue23a(&pmlmepriv->scanned_queue); |
| 64 | |
| 65 | memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct cfg80211_ssid)); |
| 66 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 67 | rtw_clear_scan_deny(padapter); |
| 68 | |
| 69 | rtw_init_mlme_timer(padapter); |
Roberta Dobrescu | 038b703 | 2014-10-26 23:30:09 +0200 | [diff] [blame] | 70 | return _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 71 | } |
| 72 | |
Larry Finger | c17416e | 2014-03-28 21:37:42 -0500 | [diff] [blame] | 73 | #ifdef CONFIG_8723AU_AP_MODE |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 74 | static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) |
| 75 | { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 76 | if (*ppie) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 77 | kfree(*ppie); |
| 78 | *plen = 0; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 79 | *ppie = NULL; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 80 | } |
| 81 | } |
Larry Finger | c17416e | 2014-03-28 21:37:42 -0500 | [diff] [blame] | 82 | #endif |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 83 | |
| 84 | void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) |
| 85 | { |
| 86 | #ifdef CONFIG_8723AU_AP_MODE |
| 87 | kfree(pmlmepriv->assoc_req); |
| 88 | kfree(pmlmepriv->assoc_rsp); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 89 | rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, |
| 90 | &pmlmepriv->wps_probe_req_ie_len); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 91 | #endif |
| 92 | } |
| 93 | |
Jes Sorensen | e418361 | 2014-04-15 19:44:47 +0200 | [diff] [blame] | 94 | void rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 95 | { |
Jes Sorensen | e418361 | 2014-04-15 19:44:47 +0200 | [diff] [blame] | 96 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 97 | ("rtw_free_mlme_priv23a\n")); |
| 98 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 99 | rtw23a_free_mlme_priv_ie_data(pmlmepriv); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 100 | } |
| 101 | |
Clément Calmels | 809d208 | 2014-06-26 10:20:46 +0200 | [diff] [blame] | 102 | struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv, gfp_t gfp) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 103 | { |
| 104 | struct wlan_network *pnetwork; |
| 105 | |
Jes Sorensen | ec838b0 | 2014-05-09 15:03:46 +0200 | [diff] [blame] | 106 | pnetwork = kzalloc(sizeof(struct wlan_network), gfp); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 107 | if (pnetwork) { |
| 108 | INIT_LIST_HEAD(&pnetwork->list); |
| 109 | pnetwork->network_type = 0; |
| 110 | pnetwork->fixed = false; |
| 111 | pnetwork->last_scanned = jiffies; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 112 | pnetwork->join_res = 0; |
| 113 | } |
| 114 | |
| 115 | return pnetwork; |
| 116 | } |
| 117 | |
Jes Sorensen | dff2226 | 2014-04-15 19:44:52 +0200 | [diff] [blame] | 118 | static void _rtw_free_network23a(struct mlme_priv *pmlmepriv, |
Jes Sorensen | 2ccac5f | 2014-04-26 18:55:50 +0200 | [diff] [blame] | 119 | struct wlan_network *pnetwork) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 120 | { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 121 | if (!pnetwork) |
| 122 | return; |
| 123 | |
| 124 | if (pnetwork->fixed == true) |
| 125 | return; |
| 126 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 127 | list_del_init(&pnetwork->list); |
| 128 | |
| 129 | kfree(pnetwork); |
| 130 | } |
| 131 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 132 | /* |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 133 | return the wlan_network with the matching addr |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 134 | |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 135 | Shall be called under atomic context... to avoid possible racing condition... |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 136 | */ |
| 137 | struct wlan_network * |
Jes Sorensen | f56d968 | 2014-04-26 18:55:48 +0200 | [diff] [blame] | 138 | rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 139 | { |
| 140 | struct list_head *phead, *plist; |
| 141 | struct wlan_network *pnetwork = NULL; |
| 142 | |
| 143 | if (is_zero_ether_addr(addr)) { |
| 144 | pnetwork = NULL; |
| 145 | goto exit; |
| 146 | } |
| 147 | |
| 148 | /* spin_lock_bh(&scanned_queue->lock); */ |
| 149 | |
| 150 | phead = get_list_head(scanned_queue); |
| 151 | plist = phead->next; |
| 152 | |
| 153 | while (plist != phead) { |
| 154 | pnetwork = container_of(plist, struct wlan_network, list); |
| 155 | |
| 156 | if (ether_addr_equal(addr, pnetwork->network.MacAddress)) |
| 157 | break; |
| 158 | |
| 159 | plist = plist->next; |
Greg Donald | a82b4b0 | 2014-09-08 20:50:23 -0500 | [diff] [blame] | 160 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 161 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 162 | if (plist == phead) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 163 | pnetwork = NULL; |
| 164 | |
| 165 | /* spin_unlock_bh(&scanned_queue->lock); */ |
| 166 | |
| 167 | exit: |
| 168 | |
| 169 | return pnetwork; |
| 170 | } |
| 171 | |
Jes Sorensen | 528e5c1 | 2014-04-26 18:55:51 +0200 | [diff] [blame] | 172 | void rtw_free_network_queue23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 173 | { |
| 174 | struct list_head *phead, *plist, *ptmp; |
| 175 | struct wlan_network *pnetwork; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 176 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 177 | struct rtw_queue *scanned_queue = &pmlmepriv->scanned_queue; |
| 178 | |
| 179 | spin_lock_bh(&scanned_queue->lock); |
| 180 | |
| 181 | phead = get_list_head(scanned_queue); |
| 182 | |
| 183 | list_for_each_safe(plist, ptmp, phead) { |
| 184 | pnetwork = container_of(plist, struct wlan_network, list); |
| 185 | |
Jes Sorensen | 2ccac5f | 2014-04-26 18:55:50 +0200 | [diff] [blame] | 186 | _rtw_free_network23a(pmlmepriv, pnetwork); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | spin_unlock_bh(&scanned_queue->lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 190 | } |
| 191 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 192 | int rtw_if_up23a(struct rtw_adapter *padapter) |
| 193 | { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 194 | int res; |
| 195 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 196 | if (padapter->bDriverStopped || padapter->bSurpriseRemoved || |
Jes Sorensen | 0618dbc | 2014-05-25 22:43:06 +0200 | [diff] [blame] | 197 | !check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 198 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
| 199 | ("rtw_if_up23a:bDriverStopped(%d) OR " |
| 200 | "bSurpriseRemoved(%d)", padapter->bDriverStopped, |
| 201 | padapter->bSurpriseRemoved)); |
| 202 | res = false; |
| 203 | } else |
| 204 | res = true; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 205 | |
| 206 | return res; |
| 207 | } |
| 208 | |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 209 | void rtw_generate_random_ibss23a(u8 *pibss) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 210 | { |
| 211 | unsigned long curtime = jiffies; |
| 212 | |
| 213 | pibss[0] = 0x02; /* in ad-hoc mode bit1 must set to 1 */ |
| 214 | pibss[1] = 0x11; |
| 215 | pibss[2] = 0x87; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 216 | pibss[3] = curtime & 0xff;/* p[0]; */ |
| 217 | pibss[4] = (curtime >> 8) & 0xff;/* p[1]; */ |
| 218 | pibss[5] = (curtime >> 16) & 0xff;/* p[2]; */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 219 | } |
| 220 | |
Jes Sorensen | a9339fd | 2014-04-15 19:44:51 +0200 | [diff] [blame] | 221 | void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming) |
| 222 | { |
| 223 | if (to_roaming == 0) |
| 224 | adapter->mlmepriv.to_join = false; |
| 225 | adapter->mlmepriv.to_roaming = to_roaming; |
| 226 | } |
| 227 | |
Jes Sorensen | afa7e48 | 2014-04-15 19:44:50 +0200 | [diff] [blame] | 228 | static void _rtw_roaming(struct rtw_adapter *padapter, |
| 229 | struct wlan_network *tgt_network) |
| 230 | { |
| 231 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 232 | struct wlan_network *pnetwork; |
| 233 | int do_join_r; |
| 234 | |
| 235 | if (tgt_network) |
| 236 | pnetwork = tgt_network; |
| 237 | else |
| 238 | pnetwork = &pmlmepriv->cur_network; |
| 239 | |
| 240 | if (padapter->mlmepriv.to_roaming > 0) { |
| 241 | DBG_8723A("roaming from %s("MAC_FMT"), length:%d\n", |
| 242 | pnetwork->network.Ssid.ssid, |
| 243 | MAC_ARG(pnetwork->network.MacAddress), |
| 244 | pnetwork->network.Ssid.ssid_len); |
| 245 | memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid, |
| 246 | sizeof(struct cfg80211_ssid)); |
| 247 | |
| 248 | pmlmepriv->assoc_by_bssid = false; |
| 249 | |
| 250 | while (1) { |
Jes Sorensen | e007b4c | 2014-06-09 15:17:00 +0200 | [diff] [blame] | 251 | do_join_r = rtw_do_join(padapter); |
Jes Sorensen | afa7e48 | 2014-04-15 19:44:50 +0200 | [diff] [blame] | 252 | if (do_join_r == _SUCCESS) |
| 253 | break; |
| 254 | else { |
| 255 | DBG_8723A("roaming do_join return %d\n", |
| 256 | do_join_r); |
| 257 | pmlmepriv->to_roaming--; |
| 258 | |
| 259 | if (padapter->mlmepriv.to_roaming > 0) |
| 260 | continue; |
| 261 | else { |
| 262 | DBG_8723A("%s(%d) -to roaming fail, " |
| 263 | "indicate_disconnect\n", |
| 264 | __func__, __LINE__); |
| 265 | rtw_indicate_disconnect23a(padapter); |
| 266 | break; |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | void rtw23a_roaming(struct rtw_adapter *padapter, |
| 274 | struct wlan_network *tgt_network) |
| 275 | { |
| 276 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 277 | |
| 278 | spin_lock_bh(&pmlmepriv->lock); |
| 279 | _rtw_roaming(padapter, tgt_network); |
| 280 | spin_unlock_bh(&pmlmepriv->lock); |
| 281 | } |
| 282 | |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 283 | static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, |
| 284 | struct wlan_network *pnetwork) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 285 | { |
Jes Sorensen | 2d5eafc | 2014-04-26 18:55:52 +0200 | [diff] [blame] | 286 | _rtw_free_network23a(pmlmepriv, pnetwork); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 287 | } |
| 288 | |
Jes Sorensen | ec36ce2 | 2014-06-09 15:16:36 +0200 | [diff] [blame] | 289 | bool rtw_is_same_ibss23a(struct rtw_adapter *adapter, |
| 290 | struct wlan_network *pnetwork) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 291 | { |
Jes Sorensen | ec36ce2 | 2014-06-09 15:16:36 +0200 | [diff] [blame] | 292 | int ret; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 293 | struct security_priv *psecuritypriv = &adapter->securitypriv; |
| 294 | |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 295 | if (psecuritypriv->dot11PrivacyAlgrthm != 0 && |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 296 | pnetwork->network.Privacy == 0) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 297 | ret = false; |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 298 | else if (psecuritypriv->dot11PrivacyAlgrthm == 0 && |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 299 | pnetwork->network.Privacy == 1) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 300 | ret = false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 301 | else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 302 | ret = true; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 303 | |
| 304 | return ret; |
| 305 | } |
| 306 | |
| 307 | inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b); |
| 308 | inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) |
| 309 | { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 310 | return (a->Ssid.ssid_len == b->Ssid.ssid_len) && |
| 311 | !memcmp(a->Ssid.ssid, b->Ssid.ssid, a->Ssid.ssid_len); |
| 312 | } |
| 313 | |
| 314 | int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) |
| 315 | { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 316 | u16 s_cap, d_cap; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 317 | |
Jes Sorensen | ccb1bdc | 2014-06-19 11:37:25 +0200 | [diff] [blame] | 318 | s_cap = src->capability; |
| 319 | d_cap = dst->capability; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 320 | |
| 321 | return ((src->Ssid.ssid_len == dst->Ssid.ssid_len) && |
Jes Sorensen | 37cb982 | 2014-05-21 09:37:40 +0200 | [diff] [blame] | 322 | /* (src->DSConfig == dst->DSConfig) && */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 323 | ether_addr_equal(src->MacAddress, dst->MacAddress) && |
Jes Sorensen | 8b3d9cd | 2014-05-31 18:05:09 +0200 | [diff] [blame] | 324 | !memcmp(src->Ssid.ssid, dst->Ssid.ssid, src->Ssid.ssid_len) && |
| 325 | (s_cap & WLAN_CAPABILITY_IBSS) == |
| 326 | (d_cap & WLAN_CAPABILITY_IBSS) && |
| 327 | (s_cap & WLAN_CAPABILITY_ESS) == (d_cap & WLAN_CAPABILITY_ESS)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 328 | } |
| 329 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 330 | struct wlan_network * |
| 331 | rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 332 | { |
| 333 | struct list_head *plist, *phead; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 334 | struct wlan_network *pwlan; |
| 335 | struct wlan_network *oldest = NULL; |
| 336 | |
| 337 | phead = get_list_head(scanned_queue); |
| 338 | |
| 339 | list_for_each(plist, phead) { |
| 340 | pwlan = container_of(plist, struct wlan_network, list); |
| 341 | |
| 342 | if (pwlan->fixed != true) { |
| 343 | if (!oldest || time_after(oldest->last_scanned, |
| 344 | pwlan->last_scanned)) |
| 345 | oldest = pwlan; |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | return oldest; |
| 350 | } |
| 351 | |
| 352 | void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 353 | struct rtw_adapter *padapter, bool update_ie) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 354 | { |
Jes Sorensen | 60b152c | 2014-10-10 21:41:36 +0200 | [diff] [blame] | 355 | u8 ss_ori = dst->SignalStrength; |
| 356 | u8 sq_ori = dst->SignalQuality; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 357 | long rssi_ori = dst->Rssi; |
| 358 | |
Jes Sorensen | 60b152c | 2014-10-10 21:41:36 +0200 | [diff] [blame] | 359 | u8 ss_smp = src->SignalStrength; |
| 360 | u8 sq_smp = src->SignalQuality; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 361 | long rssi_smp = src->Rssi; |
| 362 | |
| 363 | u8 ss_final; |
| 364 | u8 sq_final; |
| 365 | long rssi_final; |
| 366 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 367 | DBG_8723A("%s %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, " |
| 368 | "ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n", |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 369 | __func__, src->Ssid.ssid, src->MacAddress, |
Jes Sorensen | 37cb982 | 2014-05-21 09:37:40 +0200 | [diff] [blame] | 370 | src->DSConfig, ss_ori, sq_ori, rssi_ori, |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 371 | ss_smp, sq_smp, rssi_smp |
| 372 | ); |
| 373 | |
| 374 | /* The rule below is 1/5 for sample value, 4/5 for history value */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 375 | if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && |
| 376 | is_same_network23a(&padapter->mlmepriv.cur_network.network, src)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 377 | /* Take the recvpriv's value for the connected AP*/ |
| 378 | ss_final = padapter->recvpriv.signal_strength; |
| 379 | sq_final = padapter->recvpriv.signal_qual; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 380 | /* the rssi value here is undecorated, and will be |
| 381 | used for antenna diversity */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 382 | if (sq_smp != 101) /* from the right channel */ |
| 383 | rssi_final = (src->Rssi+dst->Rssi*4)/5; |
| 384 | else |
| 385 | rssi_final = rssi_ori; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 386 | } else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 387 | if (sq_smp != 101) { /* from the right channel */ |
Jes Sorensen | 60b152c | 2014-10-10 21:41:36 +0200 | [diff] [blame] | 388 | ss_final = ((u32)src->SignalStrength + |
| 389 | (u32)dst->SignalStrength * 4) / 5; |
| 390 | sq_final = ((u32)src->SignalQuality + |
| 391 | (u32)dst->SignalQuality * 4) / 5; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 392 | rssi_final = src->Rssi+dst->Rssi * 4 / 5; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 393 | } else { |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 394 | /* bss info not receiving from the right channel, use |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 395 | the original RX signal infos */ |
Jes Sorensen | 60b152c | 2014-10-10 21:41:36 +0200 | [diff] [blame] | 396 | ss_final = dst->SignalStrength; |
| 397 | sq_final = dst->SignalQuality; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 398 | rssi_final = dst->Rssi; |
| 399 | } |
| 400 | |
| 401 | } |
| 402 | |
| 403 | if (update_ie) |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 404 | memcpy(dst, src, get_wlan_bssid_ex_sz(src)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 405 | |
Jes Sorensen | 60b152c | 2014-10-10 21:41:36 +0200 | [diff] [blame] | 406 | dst->SignalStrength = ss_final; |
| 407 | dst->SignalQuality = sq_final; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 408 | dst->Rssi = rssi_final; |
| 409 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 410 | DBG_8723A("%s %s(%pM), SignalStrength:%u, SignalQuality:%u, " |
| 411 | "RawRSSI:%ld\n", __func__, dst->Ssid.ssid, dst->MacAddress, |
Jes Sorensen | 60b152c | 2014-10-10 21:41:36 +0200 | [diff] [blame] | 412 | dst->SignalStrength, dst->SignalQuality, dst->Rssi); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 413 | } |
| 414 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 415 | static void update_current_network(struct rtw_adapter *adapter, |
| 416 | struct wlan_bssid_ex *pnetwork) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 417 | { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 418 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 419 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 420 | if (check_fwstate(pmlmepriv, _FW_LINKED) && |
| 421 | is_same_network23a(&pmlmepriv->cur_network.network, pnetwork)) { |
| 422 | update_network23a(&pmlmepriv->cur_network.network, |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 423 | pnetwork, adapter, true); |
Jes Sorensen | c164bcf | 2014-05-21 09:37:41 +0200 | [diff] [blame] | 424 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 425 | rtw_update_protection23a(adapter, |
Jes Sorensen | 68e6c79 | 2014-06-24 15:03:29 +0200 | [diff] [blame] | 426 | pmlmepriv->cur_network.network.IEs, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 427 | pmlmepriv->cur_network.network.IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 428 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | /* |
| 432 | |
| 433 | Caller must hold pmlmepriv->lock first. |
| 434 | |
| 435 | */ |
Jes Sorensen | 8ab7bdb | 2014-06-09 15:16:27 +0200 | [diff] [blame] | 436 | static void rtw_update_scanned_network(struct rtw_adapter *adapter, |
| 437 | struct wlan_bssid_ex *target) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 438 | { |
| 439 | struct list_head *plist, *phead; |
| 440 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
| 441 | struct wlan_network *pnetwork = NULL; |
| 442 | struct wlan_network *oldest = NULL; |
| 443 | struct rtw_queue *queue = &pmlmepriv->scanned_queue; |
| 444 | u32 bssid_ex_sz; |
| 445 | int found = 0; |
| 446 | |
| 447 | spin_lock_bh(&queue->lock); |
| 448 | phead = get_list_head(queue); |
| 449 | |
| 450 | list_for_each(plist, phead) { |
| 451 | pnetwork = container_of(plist, struct wlan_network, list); |
| 452 | |
| 453 | if (is_same_network23a(&pnetwork->network, target)) { |
| 454 | found = 1; |
| 455 | break; |
| 456 | } |
| 457 | if (!oldest || time_after(oldest->last_scanned, |
| 458 | pnetwork->last_scanned)) |
| 459 | oldest = pnetwork; |
| 460 | } |
| 461 | |
| 462 | /* If we didn't find a match, then get a new network slot to initialize |
| 463 | * with this beacon's information */ |
| 464 | if (!found) { |
Jes Sorensen | ec838b0 | 2014-05-09 15:03:46 +0200 | [diff] [blame] | 465 | pnetwork = rtw_alloc_network(pmlmepriv, GFP_ATOMIC); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 466 | if (!pnetwork) { |
| 467 | if (!oldest) { |
| 468 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 469 | ("\n\n\nsomething wrong here\n\n\n")); |
| 470 | goto exit; |
| 471 | } |
| 472 | pnetwork = oldest; |
| 473 | } else |
| 474 | list_add_tail(&pnetwork->list, &queue->queue); |
| 475 | |
| 476 | bssid_ex_sz = get_wlan_bssid_ex_sz(target); |
| 477 | target->Length = bssid_ex_sz; |
| 478 | memcpy(&pnetwork->network, target, bssid_ex_sz); |
| 479 | |
| 480 | /* variable initialize */ |
| 481 | pnetwork->fixed = false; |
| 482 | pnetwork->last_scanned = jiffies; |
| 483 | |
| 484 | pnetwork->network_type = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 485 | pnetwork->join_res = 0; |
| 486 | |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 487 | /* bss info not receiving from the right channel */ |
Jes Sorensen | 60b152c | 2014-10-10 21:41:36 +0200 | [diff] [blame] | 488 | if (pnetwork->network.SignalQuality == 101) |
| 489 | pnetwork->network.SignalQuality = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 490 | } else { |
| 491 | /* |
| 492 | * we have an entry and we are going to update it. But |
| 493 | * this entry may be already expired. In this case we |
| 494 | * do the same as we found a new net and call the |
| 495 | * new_net handler |
| 496 | */ |
| 497 | bool update_ie = true; |
| 498 | |
| 499 | pnetwork->last_scanned = jiffies; |
| 500 | |
| 501 | /* target.reserved == 1, means that scanned network is |
| 502 | * a bcn frame. */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 503 | if (pnetwork->network.IELength > target->IELength && |
| 504 | target->reserved == 1) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 505 | update_ie = false; |
| 506 | |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 507 | update_network23a(&pnetwork->network, target, adapter, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 508 | update_ie); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | exit: |
| 512 | spin_unlock_bh(&queue->lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 513 | } |
| 514 | |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 515 | static void rtw_add_network(struct rtw_adapter *adapter, |
| 516 | struct wlan_bssid_ex *pnetwork) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 517 | { |
| 518 | update_current_network(adapter, pnetwork); |
Jes Sorensen | 8ab7bdb | 2014-06-09 15:16:27 +0200 | [diff] [blame] | 519 | rtw_update_scanned_network(adapter, pnetwork); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | /* select the desired network based on the capability of the (i)bss. */ |
| 523 | /* check items: (1) security */ |
| 524 | /* (2) network_type */ |
| 525 | /* (3) WMM */ |
| 526 | /* (4) HT */ |
| 527 | /* (5) others */ |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 528 | static int rtw_is_desired_network(struct rtw_adapter *adapter, |
| 529 | struct wlan_network *pnetwork) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 530 | { |
| 531 | struct security_priv *psecuritypriv = &adapter->securitypriv; |
| 532 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
| 533 | u32 desired_encmode; |
| 534 | u32 privacy; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 535 | int bselected = true; |
| 536 | |
| 537 | desired_encmode = psecuritypriv->ndisencryptstatus; |
| 538 | privacy = pnetwork->network.Privacy; |
| 539 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 540 | if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { |
Jes Sorensen | 9c40e12 | 2014-06-09 15:15:55 +0200 | [diff] [blame] | 541 | if (cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, |
| 542 | WLAN_OUI_TYPE_MICROSOFT_WPA, |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 543 | pnetwork->network.IEs, |
| 544 | pnetwork->network.IELength)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 545 | return true; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 546 | else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 547 | return false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 548 | } |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 549 | if (adapter->registrypriv.wifi_spec == 1) { |
| 550 | /* for correct flow of 8021X to do.... */ |
| 551 | if (desired_encmode == Ndis802_11EncryptionDisabled && |
| 552 | privacy != 0) |
Greg Donald | a82b4b0 | 2014-09-08 20:50:23 -0500 | [diff] [blame] | 553 | bselected = false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 554 | } |
| 555 | |
Jes Sorensen | 8b3d9cd | 2014-05-31 18:05:09 +0200 | [diff] [blame] | 556 | if (desired_encmode != Ndis802_11EncryptionDisabled && privacy == 0) { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 557 | DBG_8723A("desired_encmode: %d, privacy: %d\n", |
| 558 | desired_encmode, privacy); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 559 | bselected = false; |
| 560 | } |
| 561 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 562 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 563 | if (pnetwork->network.ifmode != |
| 564 | pmlmepriv->cur_network.network.ifmode) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 565 | bselected = false; |
| 566 | } |
| 567 | |
| 568 | return bselected; |
| 569 | } |
| 570 | |
| 571 | /* TODO: Perry : For Power Management */ |
Jes Sorensen | e260196 | 2014-05-09 15:03:19 +0200 | [diff] [blame] | 572 | void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 573 | { |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 574 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 575 | ("receive atimdone_evet\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 576 | } |
| 577 | |
Jes Sorensen | e260196 | 2014-05-09 15:03:19 +0200 | [diff] [blame] | 578 | void rtw_survey_event_cb23a(struct rtw_adapter *adapter, const u8 *pbuf) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 579 | { |
| 580 | u32 len; |
| 581 | struct wlan_bssid_ex *pnetwork; |
Jes Sorensen | 8b3d9cd | 2014-05-31 18:05:09 +0200 | [diff] [blame] | 582 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
Jes Sorensen | 7195dc0 | 2014-06-09 15:16:28 +0200 | [diff] [blame] | 583 | struct survey_event *survey = (struct survey_event *)pbuf; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 584 | |
Jes Sorensen | 2468796 | 2014-06-09 15:16:29 +0200 | [diff] [blame] | 585 | pnetwork = survey->bss; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 586 | |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 587 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 588 | ("rtw_survey_event_cb23a, ssid=%s\n", pnetwork->Ssid.ssid)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 589 | |
| 590 | len = get_wlan_bssid_ex_sz(pnetwork); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 591 | if (len > (sizeof(struct wlan_bssid_ex))) { |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 592 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 593 | ("\n ****rtw_survey_event_cb23a: return a wrong " |
| 594 | "bss ***\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 595 | return; |
| 596 | } |
| 597 | |
| 598 | spin_lock_bh(&pmlmepriv->lock); |
| 599 | |
| 600 | /* update IBSS_network 's timestamp */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 601 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { |
| 602 | /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 603 | "rtw_survey_event_cb23a : WIFI_ADHOC_MASTER_STATE\n\n"); */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 604 | if (ether_addr_equal(pmlmepriv->cur_network.network.MacAddress, |
| 605 | pnetwork->MacAddress)) { |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 606 | struct wlan_network *ibss_wlan; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 607 | |
Jes Sorensen | eb4f07b | 2014-06-21 16:50:16 +0200 | [diff] [blame] | 608 | pmlmepriv->cur_network.network.beacon_interval = |
| 609 | pnetwork->beacon_interval; |
| 610 | pmlmepriv->cur_network.network.capability = |
| 611 | pnetwork->capability; |
| 612 | pmlmepriv->cur_network.network.tsf = pnetwork->tsf; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 613 | spin_lock_bh(&pmlmepriv->scanned_queue.lock); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 614 | ibss_wlan = rtw_find_network23a( |
| 615 | &pmlmepriv->scanned_queue, |
| 616 | pnetwork->MacAddress); |
| 617 | if (ibss_wlan) { |
Jes Sorensen | eb4f07b | 2014-06-21 16:50:16 +0200 | [diff] [blame] | 618 | pmlmepriv->cur_network.network.beacon_interval = |
| 619 | ibss_wlan->network.beacon_interval; |
| 620 | pmlmepriv->cur_network.network.capability = |
| 621 | ibss_wlan->network.capability; |
| 622 | pmlmepriv->cur_network.network.tsf = |
| 623 | ibss_wlan->network.tsf; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 624 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
| 625 | goto exit; |
| 626 | } |
| 627 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | /* lock pmlmepriv->lock when you accessing network_q */ |
Jes Sorensen | 0618dbc | 2014-05-25 22:43:06 +0200 | [diff] [blame] | 632 | if (!check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { |
Greg Donald | a82b4b0 | 2014-09-08 20:50:23 -0500 | [diff] [blame] | 633 | if (pnetwork->Ssid.ssid[0] == 0) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 634 | pnetwork->Ssid.ssid_len = 0; |
| 635 | |
| 636 | rtw_add_network(adapter, pnetwork); |
| 637 | } |
| 638 | |
| 639 | exit: |
| 640 | |
| 641 | spin_unlock_bh(&pmlmepriv->lock); |
| 642 | |
Jes Sorensen | 2468796 | 2014-06-09 15:16:29 +0200 | [diff] [blame] | 643 | kfree(survey->bss); |
| 644 | survey->bss = NULL; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 645 | } |
| 646 | |
Jes Sorensen | e260196 | 2014-05-09 15:03:19 +0200 | [diff] [blame] | 647 | void |
| 648 | rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 649 | { |
Jes Sorensen | 8b3d9cd | 2014-05-31 18:05:09 +0200 | [diff] [blame] | 650 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 651 | struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; |
Jes Sorensen | e5c4db0 | 2014-06-09 15:16:55 +0200 | [diff] [blame] | 652 | int ret; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 653 | |
| 654 | spin_lock_bh(&pmlmepriv->lock); |
| 655 | |
| 656 | if (pmlmepriv->wps_probe_req_ie) { |
| 657 | pmlmepriv->wps_probe_req_ie_len = 0; |
| 658 | kfree(pmlmepriv->wps_probe_req_ie); |
| 659 | pmlmepriv->wps_probe_req_ie = NULL; |
| 660 | } |
| 661 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 662 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
| 663 | ("rtw_surveydone_event_callback23a: fw_state:%x\n\n", |
| 664 | get_fwstate(pmlmepriv))); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 665 | |
| 666 | if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { |
| 667 | del_timer_sync(&pmlmepriv->scan_to_timer); |
| 668 | |
| 669 | _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); |
| 670 | } else { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 671 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 672 | ("nic status =%x, survey done event comes too late!\n", |
| 673 | get_fwstate(pmlmepriv))); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | rtw_set_signal_stat_timer(&adapter->recvpriv); |
| 677 | |
| 678 | if (pmlmepriv->to_join == true) { |
Jes Sorensen | 66ed1bc | 2014-06-09 15:16:56 +0200 | [diff] [blame] | 679 | set_fwstate(pmlmepriv, _FW_UNDER_LINKING); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 680 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { |
Jes Sorensen | e5c4db0 | 2014-06-09 15:16:55 +0200 | [diff] [blame] | 681 | ret = rtw_select_and_join_from_scanned_queue23a( |
| 682 | pmlmepriv); |
| 683 | if (ret != _SUCCESS) |
| 684 | rtw_do_join_adhoc(adapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 685 | } else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 686 | pmlmepriv->to_join = false; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 687 | ret = rtw_select_and_join_from_scanned_queue23a( |
| 688 | pmlmepriv); |
Jes Sorensen | 85b3c5e | 2014-06-09 15:16:57 +0200 | [diff] [blame] | 689 | if (ret != _SUCCESS) { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 690 | DBG_8723A("try_to_join, but select scanning " |
| 691 | "queue fail, to_roaming:%d\n", |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 692 | adapter->mlmepriv.to_roaming); |
| 693 | if (adapter->mlmepriv.to_roaming) { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 694 | if (--pmlmepriv->to_roaming == 0 || |
| 695 | rtw_sitesurvey_cmd23a( |
| 696 | adapter, |
| 697 | &pmlmepriv->assoc_ssid, 1, |
| 698 | NULL, 0) != _SUCCESS) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 699 | rtw_set_roaming(adapter, 0); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 700 | rtw_free_assoc_resources23a( |
| 701 | adapter, 1); |
| 702 | rtw_indicate_disconnect23a( |
| 703 | adapter); |
| 704 | } else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 705 | pmlmepriv->to_join = true; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 706 | } |
| 707 | _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | spin_unlock_bh(&pmlmepriv->lock); |
| 713 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 714 | rtw_os_xmit_schedule23a(adapter); |
| 715 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 716 | if (pmlmeext->sitesurvey_res.bss_cnt == 0) |
Jes Sorensen | b7c19c2 | 2014-05-16 10:04:00 +0200 | [diff] [blame] | 717 | rtw_sreset_reset(adapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 718 | |
| 719 | rtw_cfg80211_surveydone_event_callback(adapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 720 | } |
| 721 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 722 | static void free_scanqueue(struct mlme_priv *pmlmepriv) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 723 | { |
| 724 | struct wlan_network *pnetwork; |
| 725 | struct rtw_queue *scan_queue = &pmlmepriv->scanned_queue; |
| 726 | struct list_head *plist, *phead, *ptemp; |
| 727 | |
| 728 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+free_scanqueue\n")); |
| 729 | spin_lock_bh(&scan_queue->lock); |
| 730 | |
| 731 | phead = get_list_head(scan_queue); |
| 732 | |
| 733 | list_for_each_safe(plist, ptemp, phead) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 734 | pnetwork = container_of(plist, struct wlan_network, list); |
Jes Sorensen | 46805ac | 2014-06-09 15:16:32 +0200 | [diff] [blame] | 735 | pnetwork->fixed = false; |
| 736 | _rtw_free_network23a(pmlmepriv, pnetwork); |
Greg Donald | a82b4b0 | 2014-09-08 20:50:23 -0500 | [diff] [blame] | 737 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 738 | |
| 739 | spin_unlock_bh(&scan_queue->lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | /* |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 743 | *rtw_free_assoc_resources23a: the caller has to lock pmlmepriv->lock |
| 744 | */ |
| 745 | void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, |
| 746 | int lock_scanned_queue) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 747 | { |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 748 | struct wlan_network *pwlan; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 749 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
| 750 | struct sta_priv *pstapriv = &adapter->stapriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 751 | struct wlan_network *tgt_network = &pmlmepriv->cur_network; |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 752 | struct sta_info *psta; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 753 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 754 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, |
| 755 | ("+rtw_free_assoc_resources23a\n")); |
| 756 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
| 757 | ("tgt_network->network.MacAddress="MAC_FMT" ssid=%s\n", |
| 758 | MAC_ARG(tgt_network->network.MacAddress), |
| 759 | tgt_network->network.Ssid.ssid)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 760 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 761 | if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) { |
| 762 | psta = rtw_get_stainfo23a(&adapter->stapriv, |
| 763 | tgt_network->network.MacAddress); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 764 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 765 | spin_lock_bh(&pstapriv->sta_hash_lock); |
| 766 | rtw_free_stainfo23a(adapter, psta); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 767 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 768 | } |
| 769 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 770 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | |
| 771 | WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 772 | rtw_free_all_stainfo23a(adapter); |
| 773 | |
| 774 | psta = rtw_get_bcmc_stainfo23a(adapter); |
| 775 | spin_lock_bh(&pstapriv->sta_hash_lock); |
| 776 | rtw_free_stainfo23a(adapter, psta); |
| 777 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 778 | |
| 779 | rtw_init_bcmc_stainfo23a(adapter); |
| 780 | } |
| 781 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 782 | if (lock_scanned_queue) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 783 | spin_lock_bh(&pmlmepriv->scanned_queue.lock); |
| 784 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 785 | pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, |
| 786 | tgt_network->network.MacAddress); |
| 787 | if (pwlan) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 788 | pwlan->fixed = false; |
| 789 | else |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 790 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 791 | ("rtw_free_assoc_resources23a : pwlan== NULL\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 792 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 793 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && |
| 794 | adapter->stapriv.asoc_sta_count == 1) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 795 | rtw_free_network_nolock(pmlmepriv, pwlan); |
| 796 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 797 | if (lock_scanned_queue) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 798 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
| 799 | |
| 800 | pmlmepriv->key_mask = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 801 | } |
| 802 | |
| 803 | /* |
| 804 | *rtw_indicate_connect23a: the caller has to lock pmlmepriv->lock |
| 805 | */ |
| 806 | void rtw_indicate_connect23a(struct rtw_adapter *padapter) |
| 807 | { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 808 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 809 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 810 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 811 | ("+rtw_indicate_connect23a\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 812 | |
| 813 | pmlmepriv->to_join = false; |
| 814 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 815 | if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 816 | set_fwstate(pmlmepriv, _FW_LINKED); |
| 817 | |
Jes Sorensen | 483557b | 2014-04-09 23:21:02 +0200 | [diff] [blame] | 818 | rtw_cfg80211_indicate_connect(padapter); |
| 819 | |
| 820 | netif_carrier_on(padapter->pnetdev); |
| 821 | |
| 822 | if (padapter->pid[2] != 0) |
| 823 | kill_pid(find_vpid(padapter->pid[2]), SIGALRM, 1); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | rtw_set_roaming(padapter, 0); |
| 827 | |
| 828 | rtw_set_scan_deny(padapter, 3000); |
| 829 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 830 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 831 | ("-rtw_indicate_connect23a: fw_state=0x%08x\n", |
| 832 | get_fwstate(pmlmepriv))); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 833 | } |
| 834 | |
| 835 | /* |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 836 | *rtw_indicate_disconnect23a: the caller has to lock pmlmepriv->lock |
| 837 | */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 838 | void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) |
| 839 | { |
Jes Sorensen | 8b3d9cd | 2014-05-31 18:05:09 +0200 | [diff] [blame] | 840 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 841 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 842 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 843 | ("+rtw_indicate_disconnect23a\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 844 | |
| 845 | _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING|WIFI_UNDER_WPS); |
| 846 | |
Greg Donald | a82b4b0 | 2014-09-08 20:50:23 -0500 | [diff] [blame] | 847 | /* DBG_8723A("clear wps when %s\n", __func__); */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 848 | |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 849 | if (padapter->mlmepriv.to_roaming > 0) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 850 | _clr_fwstate_(pmlmepriv, _FW_LINKED); |
| 851 | |
| 852 | if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) || |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 853 | padapter->mlmepriv.to_roaming <= 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 854 | rtw_os_indicate_disconnect23a(padapter); |
| 855 | |
| 856 | /* set ips_deny_time to avoid enter IPS before LPS leave */ |
| 857 | padapter->pwrctrlpriv.ips_deny_time = |
Larry Finger | c17416e | 2014-03-28 21:37:42 -0500 | [diff] [blame] | 858 | jiffies + msecs_to_jiffies(3000); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 859 | |
| 860 | _clr_fwstate_(pmlmepriv, _FW_LINKED); |
| 861 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 862 | rtw_clear_scan_deny(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 863 | } |
| 864 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 865 | rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_DISCONNECT, 1); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 866 | } |
| 867 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 868 | void rtw_scan_abort23a(struct rtw_adapter *adapter) |
| 869 | { |
| 870 | unsigned long start; |
| 871 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
| 872 | struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; |
| 873 | |
| 874 | start = jiffies; |
| 875 | pmlmeext->scan_abort = true; |
| 876 | while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) && |
| 877 | jiffies_to_msecs(jiffies - start) <= 200) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 878 | if (adapter->bDriverStopped || adapter->bSurpriseRemoved) |
| 879 | break; |
| 880 | |
Jes Sorensen | a790d58 | 2014-05-09 15:04:04 +0200 | [diff] [blame] | 881 | DBG_8723A("%s(%s): fw_state = _FW_UNDER_SURVEY!\n", |
| 882 | __func__, adapter->pnetdev->name); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 883 | msleep(20); |
| 884 | } |
| 885 | |
| 886 | if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { |
| 887 | if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) |
Jes Sorensen | a790d58 | 2014-05-09 15:04:04 +0200 | [diff] [blame] | 888 | DBG_8723A("%s(%s): waiting for scan_abort time out!\n", |
| 889 | __func__, adapter->pnetdev->name); |
Jes Sorensen | 810c832 | 2014-04-09 23:21:00 +0200 | [diff] [blame] | 890 | rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), |
| 891 | true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 892 | } |
| 893 | pmlmeext->scan_abort = false; |
| 894 | } |
| 895 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 896 | static struct sta_info * |
| 897 | rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, |
| 898 | struct wlan_network *pnetwork) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 899 | { |
| 900 | int i; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 901 | struct sta_info *bmc_sta, *psta; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 902 | struct recv_reorder_ctrl *preorder_ctrl; |
| 903 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 904 | |
| 905 | psta = rtw_get_stainfo23a(pstapriv, pnetwork->network.MacAddress); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 906 | if (!psta) |
| 907 | psta = rtw_alloc_stainfo23a(pstapriv, |
Jes Sorensen | 6e8bc71 | 2014-05-09 15:03:49 +0200 | [diff] [blame] | 908 | pnetwork->network.MacAddress, |
| 909 | GFP_ATOMIC); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 910 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 911 | if (psta) { /* update ptarget_sta */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 912 | DBG_8723A("%s\n", __func__); |
| 913 | |
| 914 | psta->aid = pnetwork->join_res; |
Jes Sorensen | dbe9849 | 2014-05-16 10:04:13 +0200 | [diff] [blame] | 915 | psta->mac_id = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 916 | |
| 917 | /* sta mode */ |
Jes Sorensen | dbe9849 | 2014-05-16 10:04:13 +0200 | [diff] [blame] | 918 | rtl8723a_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 919 | |
| 920 | /* security related */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 921 | if (padapter->securitypriv.dot11AuthAlgrthm == |
| 922 | dot11AuthAlgrthm_8021X) { |
Jes Sorensen | 9216c51 | 2014-05-21 09:37:29 +0200 | [diff] [blame] | 923 | padapter->securitypriv.binstallGrpkey = 0; |
| 924 | padapter->securitypriv.busetkipkey = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 925 | |
| 926 | psta->ieee8021x_blocked = true; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 927 | psta->dot118021XPrivacy = |
| 928 | padapter->securitypriv.dot11PrivacyAlgrthm; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 929 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 930 | memset(&psta->dot118021x_UncstKey, 0, |
| 931 | sizeof (union Keytype)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 932 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 933 | memset(&psta->dot11tkiprxmickey, 0, |
| 934 | sizeof (union Keytype)); |
| 935 | memset(&psta->dot11tkiptxmickey, 0, |
| 936 | sizeof (union Keytype)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 937 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 938 | memset(&psta->dot11txpn, 0, sizeof (union pn48)); |
| 939 | memset(&psta->dot11rxpn, 0, sizeof (union pn48)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 940 | } |
| 941 | |
| 942 | /* Commented by Albert 2012/07/21 */ |
| 943 | /* When doing the WPS, the wps_ie_len won't equal to 0 */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 944 | /* And the Wi-Fi driver shouldn't allow the data packet |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 945 | to be transmitted. */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 946 | if (padapter->securitypriv.wps_ie_len != 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 947 | psta->ieee8021x_blocked = true; |
| 948 | padapter->securitypriv.wps_ie_len = 0; |
| 949 | } |
| 950 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 951 | /* for A-MPDU Rx reordering buffer control for bmc_sta & |
| 952 | * sta_info */ |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 953 | /* if A-MPDU Rx is enabled, resetting |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 954 | rx_ordering_ctrl wstart_b(indicate_seq) to default |
| 955 | value = 0xffff */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 956 | /* todo: check if AP can send A-MPDU packets */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 957 | for (i = 0; i < 16 ; i++) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 958 | /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ |
| 959 | preorder_ctrl = &psta->recvreorder_ctrl[i]; |
| 960 | preorder_ctrl->enable = false; |
| 961 | preorder_ctrl->indicate_seq = 0xffff; |
| 962 | preorder_ctrl->wend_b = 0xffff; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 963 | /* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ |
| 964 | preorder_ctrl->wsize_b = 64; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 965 | } |
| 966 | |
| 967 | bmc_sta = rtw_get_bcmc_stainfo23a(padapter); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 968 | if (bmc_sta) { |
| 969 | for (i = 0; i < 16 ; i++) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 970 | preorder_ctrl = &bmc_sta->recvreorder_ctrl[i]; |
| 971 | preorder_ctrl->enable = false; |
| 972 | preorder_ctrl->indicate_seq = 0xffff; |
| 973 | preorder_ctrl->wend_b = 0xffff; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 974 | /* max_ampdu_sz; ex. 32(kbytes) -> |
| 975 | wsize_b = 32 */ |
| 976 | preorder_ctrl->wsize_b = 64; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 977 | } |
| 978 | } |
| 979 | |
| 980 | /* misc. */ |
| 981 | update_sta_info23a(padapter, psta); |
| 982 | |
| 983 | } |
| 984 | |
| 985 | return psta; |
| 986 | } |
| 987 | |
| 988 | /* pnetwork : returns from rtw23a_joinbss_event_cb */ |
| 989 | /* ptarget_wlan: found from scanned_queue */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 990 | static void |
| 991 | rtw_joinbss_update_network23a(struct rtw_adapter *padapter, |
| 992 | struct wlan_network *ptarget_wlan, |
| 993 | struct wlan_network *pnetwork) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 994 | { |
| 995 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 996 | struct wlan_network *cur_network = &pmlmepriv->cur_network; |
| 997 | |
| 998 | DBG_8723A("%s\n", __func__); |
| 999 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1000 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
| 1001 | ("\nfw_state:%x, BSSID:"MAC_FMT"\n", get_fwstate(pmlmepriv), |
| 1002 | MAC_ARG(pnetwork->network.MacAddress))); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1003 | |
| 1004 | /* why not use ptarget_wlan?? */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1005 | memcpy(&cur_network->network, &pnetwork->network, |
| 1006 | pnetwork->network.Length); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1007 | /* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */ |
| 1008 | cur_network->network.IELength = ptarget_wlan->network.IELength; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1009 | memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], |
| 1010 | MAX_IE_SZ); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1011 | |
Jes Sorensen | 2bde052 | 2014-06-21 16:50:17 +0200 | [diff] [blame] | 1012 | cur_network->network.capability = ptarget_wlan->network.capability; |
| 1013 | cur_network->network.beacon_interval = |
| 1014 | ptarget_wlan->network.beacon_interval; |
| 1015 | cur_network->network.tsf = ptarget_wlan->network.tsf; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1016 | |
| 1017 | rtw_set_signal_stat_timer(&padapter->recvpriv); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1018 | padapter->recvpriv.signal_strength = |
Jes Sorensen | 60b152c | 2014-10-10 21:41:36 +0200 | [diff] [blame] | 1019 | ptarget_wlan->network.SignalStrength; |
| 1020 | padapter->recvpriv.signal_qual = ptarget_wlan->network.SignalQuality; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1021 | /* |
| 1022 | * the ptarget_wlan->network.Rssi is raw data, we use |
Jes Sorensen | 60b152c | 2014-10-10 21:41:36 +0200 | [diff] [blame] | 1023 | * ptarget_wlan->network.SignalStrength instead (has scaled) |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1024 | */ |
| 1025 | padapter->recvpriv.rssi = translate_percentage_to_dbm( |
Jes Sorensen | 60b152c | 2014-10-10 21:41:36 +0200 | [diff] [blame] | 1026 | ptarget_wlan->network.SignalStrength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1027 | DBG_8723A("%s signal_strength:%3u, rssi:%3d, signal_qual:%3u\n", |
| 1028 | __func__, padapter->recvpriv.signal_strength, |
| 1029 | padapter->recvpriv.rssi, padapter->recvpriv.signal_qual); |
| 1030 | rtw_set_signal_stat_timer(&padapter->recvpriv); |
| 1031 | |
| 1032 | /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 1033 | switch (pnetwork->network.ifmode) { |
| 1034 | case NL80211_IFTYPE_P2P_CLIENT: |
| 1035 | case NL80211_IFTYPE_STATION: |
| 1036 | if (pmlmepriv->fw_state & WIFI_UNDER_WPS) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1037 | pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; |
| 1038 | else |
| 1039 | pmlmepriv->fw_state = WIFI_STATION_STATE; |
| 1040 | break; |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 1041 | case NL80211_IFTYPE_ADHOC: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1042 | pmlmepriv->fw_state = WIFI_ADHOC_STATE; |
| 1043 | break; |
| 1044 | default: |
| 1045 | pmlmepriv->fw_state = WIFI_NULL_STATE; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1046 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 1047 | ("Invalid network_mode\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1048 | break; |
| 1049 | } |
| 1050 | |
Jes Sorensen | 68e6c79 | 2014-06-24 15:03:29 +0200 | [diff] [blame] | 1051 | rtw_update_protection23a(padapter, cur_network->network.IEs, |
| 1052 | cur_network->network.IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1053 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1054 | rtw_update_ht_cap23a(padapter, cur_network->network.IEs, |
| 1055 | cur_network->network.IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1056 | } |
| 1057 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1058 | /* |
| 1059 | * Notes: |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 1060 | * the function could be > passive_level (the same context as Rx tasklet) |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1061 | * pnetwork : returns from rtw23a_joinbss_event_cb |
| 1062 | * ptarget_wlan: found from scanned_queue |
| 1063 | * if join_res > 0, for (fw_state==WIFI_STATION_STATE), |
| 1064 | * we check if "ptarget_sta" & "ptarget_wlan" exist. |
| 1065 | * if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), |
| 1066 | * we only check if "ptarget_wlan" exist. |
| 1067 | * if join_res > 0, update "cur_network->network" from "pnetwork->network" |
| 1068 | * if (ptarget_wlan !=NULL). |
| 1069 | */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1070 | |
| 1071 | void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) |
| 1072 | { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1073 | struct sta_info *ptarget_sta, *pcur_sta; |
| 1074 | struct sta_priv *pstapriv = &adapter->stapriv; |
| 1075 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
| 1076 | struct wlan_network *pnetwork = (struct wlan_network *)pbuf; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1077 | struct wlan_network *cur_network = &pmlmepriv->cur_network; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1078 | struct wlan_network *pcur_wlan, *ptarget_wlan = NULL; |
| 1079 | bool the_same_macaddr; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1080 | |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1081 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1082 | ("joinbss event call back received with res=%d\n", |
| 1083 | pnetwork->join_res)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1084 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1085 | if (pmlmepriv->assoc_ssid.ssid_len == 0) { |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1086 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1087 | ("@@@@@ joinbss event call back for Any SSid\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1088 | } else { |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1089 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1090 | ("@@@@@ rtw23a_joinbss_event_cb for SSid:%s\n", |
| 1091 | pmlmepriv->assoc_ssid.ssid)); |
| 1092 | } |
| 1093 | |
| 1094 | if (ether_addr_equal(pnetwork->network.MacAddress, |
| 1095 | cur_network->network.MacAddress)) |
| 1096 | the_same_macaddr = true; |
| 1097 | else |
| 1098 | the_same_macaddr = false; |
| 1099 | |
| 1100 | pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1101 | if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1102 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1103 | ("\n\n ***joinbss_evt_callback return a wrong bss " |
| 1104 | "***\n\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1105 | return; |
| 1106 | } |
| 1107 | |
| 1108 | spin_lock_bh(&pmlmepriv->lock); |
| 1109 | |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1110 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1111 | ("\n rtw23a_joinbss_event_cb !! _enter_critical\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1112 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1113 | if (pnetwork->join_res > 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1114 | spin_lock_bh(&pmlmepriv->scanned_queue.lock); |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1115 | if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1116 | /* s1. find ptarget_wlan */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1117 | if (check_fwstate(pmlmepriv, _FW_LINKED)) { |
Roberta Dobrescu | 08551cb | 2014-10-26 23:30:05 +0200 | [diff] [blame] | 1118 | if (the_same_macaddr) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1119 | ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1120 | } else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1121 | pcur_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1122 | if (pcur_wlan) |
| 1123 | pcur_wlan->fixed = false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1124 | |
| 1125 | pcur_sta = rtw_get_stainfo23a(pstapriv, cur_network->network.MacAddress); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1126 | if (pcur_sta) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1127 | spin_lock_bh(&pstapriv->sta_hash_lock); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1128 | rtw_free_stainfo23a(adapter, |
| 1129 | pcur_sta); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1130 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 1131 | } |
| 1132 | |
| 1133 | ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1134 | if (check_fwstate(pmlmepriv, |
| 1135 | WIFI_STATION_STATE)) { |
| 1136 | if (ptarget_wlan) |
| 1137 | ptarget_wlan->fixed = |
| 1138 | true; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1139 | } |
| 1140 | } |
| 1141 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1142 | } else { |
| 1143 | ptarget_wlan = rtw_find_network23a( |
| 1144 | &pmlmepriv->scanned_queue, |
| 1145 | pnetwork->network.MacAddress); |
| 1146 | if (check_fwstate(pmlmepriv, |
| 1147 | WIFI_STATION_STATE)) { |
| 1148 | if (ptarget_wlan) |
| 1149 | ptarget_wlan->fixed = true; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1150 | } |
| 1151 | } |
| 1152 | |
| 1153 | /* s2. update cur_network */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1154 | if (ptarget_wlan) |
| 1155 | rtw_joinbss_update_network23a(adapter, |
| 1156 | ptarget_wlan, |
| 1157 | pnetwork); |
| 1158 | else { |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1159 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1160 | ("Can't find ptarget_wlan when " |
| 1161 | "joinbss_event callback\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1162 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
| 1163 | goto ignore_joinbss_callback; |
| 1164 | } |
| 1165 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1166 | /* s3. find ptarget_sta & update ptarget_sta after |
| 1167 | update cur_network only for station mode */ |
| 1168 | if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { |
| 1169 | ptarget_sta = rtw_joinbss_update_stainfo( |
| 1170 | adapter, pnetwork); |
| 1171 | if (!ptarget_sta) { |
| 1172 | RT_TRACE(_module_rtl871x_mlme_c_, |
| 1173 | _drv_err_, |
| 1174 | ("Can't update stainfo when " |
| 1175 | "joinbss_event callback\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1176 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
| 1177 | goto ignore_joinbss_callback; |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | /* s4. indicate connect */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1182 | if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1183 | rtw_indicate_connect23a(adapter); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1184 | else { |
| 1185 | /* adhoc mode will rtw_indicate_connect23a |
| 1186 | when rtw_stassoc_event_callback23a */ |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1187 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1188 | ("adhoc mode, fw_state:%x", |
| 1189 | get_fwstate(pmlmepriv))); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1190 | } |
| 1191 | |
| 1192 | /* s5. Cancle assoc_timer */ |
| 1193 | del_timer_sync(&pmlmepriv->assoc_timer); |
| 1194 | |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1195 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1196 | ("Cancle assoc_timer\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1197 | } else { |
| 1198 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 1199 | ("rtw23a_joinbss_event_cb err: fw_state:%x", |
| 1200 | get_fwstate(pmlmepriv))); |
| 1201 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
| 1202 | goto ignore_joinbss_callback; |
| 1203 | } |
| 1204 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1205 | } else if (pnetwork->join_res == -4) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1206 | rtw_reset_securitypriv23a(adapter); |
| 1207 | mod_timer(&pmlmepriv->assoc_timer, |
| 1208 | jiffies + msecs_to_jiffies(1)); |
| 1209 | |
| 1210 | /* rtw_free_assoc_resources23a(adapter, 1); */ |
| 1211 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1212 | if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1213 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1214 | ("fail! clear _FW_UNDER_LINKING ^^^fw_state=" |
| 1215 | "%x\n", get_fwstate(pmlmepriv))); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1216 | _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); |
| 1217 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1218 | } else { |
| 1219 | /* if join_res < 0 (join fails), then try again */ |
| 1220 | mod_timer(&pmlmepriv->assoc_timer, |
| 1221 | jiffies + msecs_to_jiffies(1)); |
| 1222 | _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); |
| 1223 | } |
| 1224 | |
| 1225 | ignore_joinbss_callback: |
| 1226 | |
| 1227 | spin_unlock_bh(&pmlmepriv->lock); |
| 1228 | } |
| 1229 | |
Jes Sorensen | e260196 | 2014-05-09 15:03:19 +0200 | [diff] [blame] | 1230 | void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, const u8 *pbuf) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1231 | { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1232 | struct wlan_network *pnetwork = (struct wlan_network *)pbuf; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1233 | |
| 1234 | mlmeext_joinbss_event_callback23a(adapter, pnetwork->join_res); |
| 1235 | |
| 1236 | rtw_os_xmit_schedule23a(adapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1237 | } |
| 1238 | |
Jes Sorensen | e260196 | 2014-05-09 15:03:19 +0200 | [diff] [blame] | 1239 | void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1240 | { |
| 1241 | struct sta_info *psta; |
| 1242 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 1243 | struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1244 | struct wlan_network *cur_network = &pmlmepriv->cur_network; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1245 | struct wlan_network *ptarget_wlan; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1246 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1247 | if (rtw_access_ctrl23a(adapter, pstassoc->macaddr) == false) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1248 | return; |
| 1249 | |
| 1250 | #ifdef CONFIG_8723AU_AP_MODE |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1251 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1252 | psta = rtw_get_stainfo23a(&adapter->stapriv, pstassoc->macaddr); |
| 1253 | if (psta) { |
| 1254 | /* bss_cap_update_on_sta_join23a(adapter, psta); */ |
| 1255 | /* sta_info_update23a(adapter, psta); */ |
| 1256 | ap_sta_info_defer_update23a(adapter, psta); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1257 | } |
| 1258 | return; |
| 1259 | } |
| 1260 | #endif |
| 1261 | /* for AD-HOC mode */ |
| 1262 | psta = rtw_get_stainfo23a(&adapter->stapriv, pstassoc->macaddr); |
| 1263 | if (psta != NULL) { |
| 1264 | /* the sta have been in sta_info_queue => do nothing */ |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1265 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1266 | ("Error: rtw_stassoc_event_callback23a: sta has " |
| 1267 | "been in sta_hash_queue\n")); |
| 1268 | /* between drv has received this event before and |
| 1269 | fw have not yet to set key to CAM_ENTRY) */ |
| 1270 | return; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1271 | } |
| 1272 | |
Jes Sorensen | 6e8bc71 | 2014-05-09 15:03:49 +0200 | [diff] [blame] | 1273 | psta = rtw_alloc_stainfo23a(&adapter->stapriv, pstassoc->macaddr, |
| 1274 | GFP_KERNEL); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1275 | if (!psta) { |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1276 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1277 | ("Can't alloc sta_info when " |
| 1278 | "rtw_stassoc_event_callback23a\n")); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1279 | return; |
| 1280 | } |
| 1281 | |
| 1282 | /* to do : init sta_info variable */ |
| 1283 | psta->qos_option = 0; |
| 1284 | psta->mac_id = (uint)pstassoc->cam_id; |
| 1285 | /* psta->aid = (uint)pstassoc->cam_id; */ |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1286 | DBG_8723A("%s\n", __func__); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1287 | /* for ad-hoc mode */ |
Jes Sorensen | dbe9849 | 2014-05-16 10:04:13 +0200 | [diff] [blame] | 1288 | rtl8723a_SetHalODMVar(adapter, HAL_ODM_STA_INFO, psta, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1289 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1290 | if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) |
| 1291 | psta->dot118021XPrivacy = |
| 1292 | adapter->securitypriv.dot11PrivacyAlgrthm; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1293 | |
| 1294 | psta->ieee8021x_blocked = false; |
| 1295 | |
| 1296 | spin_lock_bh(&pmlmepriv->lock); |
| 1297 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1298 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || |
| 1299 | check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { |
| 1300 | if (adapter->stapriv.asoc_sta_count == 2) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1301 | spin_lock_bh(&pmlmepriv->scanned_queue.lock); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1302 | ptarget_wlan = |
| 1303 | rtw_find_network23a(&pmlmepriv->scanned_queue, |
| 1304 | cur_network->network.MacAddress); |
| 1305 | if (ptarget_wlan) |
| 1306 | ptarget_wlan->fixed = true; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1307 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
| 1308 | /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ |
| 1309 | rtw_indicate_connect23a(adapter); |
| 1310 | } |
| 1311 | } |
| 1312 | |
| 1313 | spin_unlock_bh(&pmlmepriv->lock); |
| 1314 | |
| 1315 | mlmeext_sta_add_event_callback23a(adapter, psta); |
| 1316 | } |
| 1317 | |
Jes Sorensen | e260196 | 2014-05-09 15:03:19 +0200 | [diff] [blame] | 1318 | void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1319 | { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1320 | int mac_id; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1321 | struct sta_info *psta; |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 1322 | struct wlan_network *pwlan; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1323 | struct wlan_bssid_ex *pdev_network; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1324 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
| 1325 | struct stadel_event *pstadel = (struct stadel_event *)pbuf; |
| 1326 | struct sta_priv *pstapriv = &adapter->stapriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1327 | struct wlan_network *tgt_network = &pmlmepriv->cur_network; |
| 1328 | |
| 1329 | psta = rtw_get_stainfo23a(&adapter->stapriv, pstadel->macaddr); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1330 | if (psta) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1331 | mac_id = psta->mac_id; |
| 1332 | else |
| 1333 | mac_id = pstadel->mac_id; |
| 1334 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1335 | DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id, |
| 1336 | MAC_ARG(pstadel->macaddr)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1337 | |
Greg Donald | a82b4b0 | 2014-09-08 20:50:23 -0500 | [diff] [blame] | 1338 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1339 | return; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1340 | |
| 1341 | mlmeext_sta_del_event_callback23a(adapter); |
| 1342 | |
| 1343 | spin_lock_bh(&pmlmepriv->lock); |
| 1344 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1345 | if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 1346 | if (adapter->mlmepriv.to_roaming > 0) { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1347 | /* this stadel_event is caused by roaming, |
| 1348 | decrease to_roaming */ |
| 1349 | pmlmepriv->to_roaming--; |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 1350 | } else if (adapter->mlmepriv.to_roaming == 0) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1351 | rtw_set_roaming(adapter, adapter->registrypriv.max_roaming_times); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1352 | if (*((u16 *)pstadel->rsvd) != WLAN_REASON_EXPIRATION_CHK) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1353 | rtw_set_roaming(adapter, 0); /* don't roam */ |
| 1354 | |
| 1355 | rtw_free_uc_swdec_pending_queue23a(adapter); |
| 1356 | |
| 1357 | rtw_free_assoc_resources23a(adapter, 1); |
| 1358 | rtw_indicate_disconnect23a(adapter); |
| 1359 | spin_lock_bh(&pmlmepriv->scanned_queue.lock); |
| 1360 | /* remove the network entry in scanned_queue */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1361 | pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, |
| 1362 | tgt_network->network.MacAddress); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1363 | if (pwlan) { |
| 1364 | pwlan->fixed = false; |
| 1365 | rtw_free_network_nolock(pmlmepriv, pwlan); |
| 1366 | } |
| 1367 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
| 1368 | |
Jes Sorensen | afa7e48 | 2014-04-15 19:44:50 +0200 | [diff] [blame] | 1369 | _rtw_roaming(adapter, tgt_network); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1370 | } |
| 1371 | |
| 1372 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1373 | check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1374 | |
| 1375 | spin_lock_bh(&pstapriv->sta_hash_lock); |
| 1376 | rtw_free_stainfo23a(adapter, psta); |
| 1377 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 1378 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1379 | /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ |
| 1380 | if (adapter->stapriv.asoc_sta_count == 1) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1381 | spin_lock_bh(&pmlmepriv->scanned_queue.lock); |
| 1382 | /* free old ibss network */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1383 | /* pwlan = rtw_find_network23a( |
| 1384 | &pmlmepriv->scanned_queue, pstadel->macaddr); */ |
| 1385 | pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, |
| 1386 | tgt_network->network.MacAddress); |
| 1387 | if (pwlan) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1388 | pwlan->fixed = false; |
| 1389 | rtw_free_network_nolock(pmlmepriv, pwlan); |
| 1390 | } |
| 1391 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
| 1392 | /* re-create ibss */ |
| 1393 | pdev_network = &adapter->registrypriv.dev_network; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1394 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1395 | memcpy(pdev_network, &tgt_network->network, |
| 1396 | get_wlan_bssid_ex_sz(&tgt_network->network)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1397 | |
Jes Sorensen | fcc6020 | 2014-06-09 15:16:53 +0200 | [diff] [blame] | 1398 | rtw_do_join_adhoc(adapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1399 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1400 | } |
| 1401 | |
| 1402 | spin_unlock_bh(&pmlmepriv->lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1403 | } |
| 1404 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1405 | /* |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 1406 | * rtw23a_join_to_handler - Timeout/failure handler for CMD JoinBss |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1407 | * @adapter: pointer to _adapter structure |
| 1408 | */ |
| 1409 | void rtw23a_join_to_handler (unsigned long data) |
| 1410 | { |
| 1411 | struct rtw_adapter *adapter = (struct rtw_adapter *)data; |
Jes Sorensen | 8b3d9cd | 2014-05-31 18:05:09 +0200 | [diff] [blame] | 1412 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1413 | int do_join_r; |
| 1414 | |
| 1415 | DBG_8723A("%s, fw_state=%x\n", __func__, get_fwstate(pmlmepriv)); |
| 1416 | |
Jes Sorensen | 8b3d9cd | 2014-05-31 18:05:09 +0200 | [diff] [blame] | 1417 | if (adapter->bDriverStopped || adapter->bSurpriseRemoved) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1418 | return; |
| 1419 | |
| 1420 | spin_lock_bh(&pmlmepriv->lock); |
| 1421 | |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 1422 | if (adapter->mlmepriv.to_roaming > 0) { |
| 1423 | /* join timeout caused by roaming */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1424 | while (1) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1425 | pmlmepriv->to_roaming--; |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 1426 | if (adapter->mlmepriv.to_roaming != 0) { |
| 1427 | /* try another */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1428 | DBG_8723A("%s try another roaming\n", __func__); |
Jes Sorensen | e007b4c | 2014-06-09 15:17:00 +0200 | [diff] [blame] | 1429 | do_join_r = rtw_do_join(adapter); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1430 | if (do_join_r != _SUCCESS) { |
| 1431 | DBG_8723A("%s roaming do_join return " |
| 1432 | "%d\n", __func__ , do_join_r); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1433 | continue; |
| 1434 | } |
| 1435 | break; |
| 1436 | } else { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1437 | DBG_8723A("%s We've try roaming but fail\n", |
| 1438 | __func__); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1439 | rtw_indicate_disconnect23a(adapter); |
| 1440 | break; |
| 1441 | } |
| 1442 | } |
| 1443 | } else { |
| 1444 | rtw_indicate_disconnect23a(adapter); |
| 1445 | free_scanqueue(pmlmepriv);/* */ |
| 1446 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1447 | /* indicate disconnect for the case that join_timeout and |
| 1448 | check_fwstate != FW_LINKED */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1449 | rtw_cfg80211_indicate_disconnect(adapter); |
| 1450 | } |
| 1451 | |
| 1452 | spin_unlock_bh(&pmlmepriv->lock); |
| 1453 | |
| 1454 | } |
| 1455 | |
| 1456 | /* |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 1457 | * rtw_scan_timeout_handler23a - Timeout/Failure handler for CMD SiteSurvey |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1458 | * @data: pointer to _adapter structure |
| 1459 | */ |
| 1460 | void rtw_scan_timeout_handler23a(unsigned long data) |
| 1461 | { |
| 1462 | struct rtw_adapter *adapter = (struct rtw_adapter *)data; |
Jes Sorensen | 8b3d9cd | 2014-05-31 18:05:09 +0200 | [diff] [blame] | 1463 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1464 | |
Jes Sorensen | 9cd613c | 2014-05-09 15:04:03 +0200 | [diff] [blame] | 1465 | DBG_8723A("%s(%s): fw_state =%x\n", __func__, adapter->pnetdev->name, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1466 | get_fwstate(pmlmepriv)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1467 | |
| 1468 | spin_lock_bh(&pmlmepriv->lock); |
| 1469 | |
| 1470 | _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); |
| 1471 | |
| 1472 | spin_unlock_bh(&pmlmepriv->lock); |
| 1473 | |
Jes Sorensen | 810c832 | 2014-04-09 23:21:00 +0200 | [diff] [blame] | 1474 | rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1475 | } |
| 1476 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1477 | void rtw_dynamic_check_timer_handler(unsigned long data) |
| 1478 | { |
| 1479 | struct rtw_adapter *adapter = (struct rtw_adapter *)data; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1480 | |
| 1481 | if (adapter->hw_init_completed == false) |
| 1482 | goto out; |
| 1483 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1484 | if (adapter->bDriverStopped == true || |
| 1485 | adapter->bSurpriseRemoved == true) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1486 | goto out; |
| 1487 | |
| 1488 | if (adapter->net_closed == true) |
| 1489 | goto out; |
| 1490 | |
| 1491 | rtw_dynamic_chk_wk_cmd23a(adapter); |
| 1492 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1493 | out: |
| 1494 | mod_timer(&adapter->mlmepriv.dynamic_chk_timer, |
| 1495 | jiffies + msecs_to_jiffies(2000)); |
| 1496 | } |
| 1497 | |
| 1498 | inline bool rtw_is_scan_deny(struct rtw_adapter *adapter) |
| 1499 | { |
| 1500 | struct mlme_priv *mlmepriv = &adapter->mlmepriv; |
Yeliz Taneroglu | 29ed932 | 2014-10-09 01:22:14 +0300 | [diff] [blame] | 1501 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1502 | return (atomic_read(&mlmepriv->set_scan_deny) != 0) ? true : false; |
| 1503 | } |
| 1504 | |
| 1505 | void rtw_clear_scan_deny(struct rtw_adapter *adapter) |
| 1506 | { |
| 1507 | struct mlme_priv *mlmepriv = &adapter->mlmepriv; |
Yeliz Taneroglu | 29ed932 | 2014-10-09 01:22:14 +0300 | [diff] [blame] | 1508 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1509 | atomic_set(&mlmepriv->set_scan_deny, 0); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1510 | } |
| 1511 | |
| 1512 | void rtw_set_scan_deny_timer_hdl(unsigned long data) |
| 1513 | { |
| 1514 | struct rtw_adapter *adapter = (struct rtw_adapter *)data; |
Yeliz Taneroglu | 29ed932 | 2014-10-09 01:22:14 +0300 | [diff] [blame] | 1515 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1516 | rtw_clear_scan_deny(adapter); |
| 1517 | } |
| 1518 | |
| 1519 | void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms) |
| 1520 | { |
| 1521 | struct mlme_priv *mlmepriv = &adapter->mlmepriv; |
| 1522 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1523 | atomic_set(&mlmepriv->set_scan_deny, 1); |
| 1524 | mod_timer(&mlmepriv->set_scan_deny_timer, |
| 1525 | jiffies + msecs_to_jiffies(ms)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1526 | } |
| 1527 | |
| 1528 | #if defined(IEEE80211_SCAN_RESULT_EXPIRE) |
Tina Ruchandani | de1de2f | 2014-10-25 16:56:01 -0700 | [diff] [blame] | 1529 | #define RTW_SCAN_RESULT_EXPIRE \ |
| 1530 | ((IEEE80211_SCAN_RESULT_EXPIRE / (HZ*1000)) - 1000) /* 3000 -1000 */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1531 | #else |
| 1532 | #define RTW_SCAN_RESULT_EXPIRE 2000 |
| 1533 | #endif |
| 1534 | |
| 1535 | /* |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1536 | * Select a new join candidate from the original @param candidate and |
| 1537 | * @param competitor |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1538 | * @return true: candidate is updated |
| 1539 | * @return false: candidate is not updated |
| 1540 | */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1541 | static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv, |
| 1542 | struct wlan_network **candidate, |
| 1543 | struct wlan_network *competitor) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1544 | { |
| 1545 | int updated = false; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1546 | struct rtw_adapter *adapter; |
| 1547 | |
| 1548 | adapter = container_of(pmlmepriv, struct rtw_adapter, mlmepriv); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1549 | |
| 1550 | /* check bssid, if needed */ |
| 1551 | if (pmlmepriv->assoc_by_bssid == true) { |
| 1552 | if (!ether_addr_equal(competitor->network.MacAddress, |
| 1553 | pmlmepriv->assoc_bssid)) |
| 1554 | goto exit; |
| 1555 | } |
| 1556 | |
| 1557 | /* check ssid, if needed */ |
Larry Finger | c17416e | 2014-03-28 21:37:42 -0500 | [diff] [blame] | 1558 | if (pmlmepriv->assoc_ssid.ssid_len) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1559 | if (competitor->network.Ssid.ssid_len != |
| 1560 | pmlmepriv->assoc_ssid.ssid_len || |
| 1561 | memcmp(competitor->network.Ssid.ssid, |
| 1562 | pmlmepriv->assoc_ssid.ssid, |
| 1563 | pmlmepriv->assoc_ssid.ssid_len)) |
| 1564 | goto exit; |
| 1565 | } |
| 1566 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1567 | if (rtw_is_desired_network(adapter, competitor) == false) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1568 | goto exit; |
| 1569 | |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 1570 | if (adapter->mlmepriv.to_roaming > 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1571 | unsigned int passed; |
| 1572 | |
| 1573 | passed = jiffies_to_msecs(jiffies - competitor->last_scanned); |
| 1574 | if (passed >= RTW_SCAN_RESULT_EXPIRE || |
| 1575 | is_same_ess(&competitor->network, |
| 1576 | &pmlmepriv->cur_network.network) == false) |
| 1577 | goto exit; |
| 1578 | } |
| 1579 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1580 | if (!*candidate || |
| 1581 | (*candidate)->network.Rssi<competitor->network.Rssi) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1582 | *candidate = competitor; |
| 1583 | updated = true; |
| 1584 | } |
| 1585 | |
| 1586 | if (updated) { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1587 | DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] " |
| 1588 | "new candidate: %s("MAC_FMT") rssi:%d\n", |
| 1589 | pmlmepriv->assoc_by_bssid, |
| 1590 | pmlmepriv->assoc_ssid.ssid, |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 1591 | adapter->mlmepriv.to_roaming, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1592 | (*candidate)->network.Ssid.ssid, |
| 1593 | MAC_ARG((*candidate)->network.MacAddress), |
| 1594 | (int)(*candidate)->network.Rssi); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1595 | } |
| 1596 | |
| 1597 | exit: |
| 1598 | return updated; |
| 1599 | } |
| 1600 | |
| 1601 | /* |
| 1602 | Calling context: |
| 1603 | The caller of the sub-routine will be in critical section... |
| 1604 | |
| 1605 | The caller must hold the following spinlock |
| 1606 | |
| 1607 | pmlmepriv->lock |
| 1608 | |
| 1609 | */ |
| 1610 | |
Jes Sorensen | e007b4c | 2014-06-09 15:17:00 +0200 | [diff] [blame] | 1611 | static int rtw_do_join(struct rtw_adapter *padapter) |
| 1612 | { |
| 1613 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1614 | int ret; |
| 1615 | |
| 1616 | pmlmepriv->cur_network.join_res = -2; |
| 1617 | |
| 1618 | set_fwstate(pmlmepriv, _FW_UNDER_LINKING); |
| 1619 | |
| 1620 | pmlmepriv->to_join = true; |
| 1621 | |
| 1622 | ret = rtw_select_and_join_from_scanned_queue23a(pmlmepriv); |
| 1623 | if (ret == _SUCCESS) { |
| 1624 | pmlmepriv->to_join = false; |
| 1625 | } else { |
| 1626 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { |
| 1627 | /* switch to ADHOC_MASTER */ |
| 1628 | ret = rtw_do_join_adhoc(padapter); |
| 1629 | if (ret != _SUCCESS) |
| 1630 | goto exit; |
| 1631 | } else { |
| 1632 | /* can't associate ; reset under-linking */ |
| 1633 | _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); |
| 1634 | |
| 1635 | ret = _FAIL; |
| 1636 | pmlmepriv->to_join = false; |
| 1637 | } |
| 1638 | } |
| 1639 | |
| 1640 | exit: |
| 1641 | return ret; |
| 1642 | } |
| 1643 | |
Jes Sorensen | 0e634a0 | 2014-06-09 15:16:49 +0200 | [diff] [blame] | 1644 | static struct wlan_network * |
| 1645 | rtw_select_candidate_from_queue(struct mlme_priv *pmlmepriv) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1646 | { |
Jes Sorensen | 0e634a0 | 2014-06-09 15:16:49 +0200 | [diff] [blame] | 1647 | struct wlan_network *pnetwork, *candidate = NULL; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1648 | struct rtw_queue *queue = &pmlmepriv->scanned_queue; |
Jes Sorensen | 0e634a0 | 2014-06-09 15:16:49 +0200 | [diff] [blame] | 1649 | struct list_head *phead, *plist, *ptmp; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1650 | |
| 1651 | spin_lock_bh(&pmlmepriv->scanned_queue.lock); |
| 1652 | phead = get_list_head(queue); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1653 | |
| 1654 | list_for_each_safe(plist, ptmp, phead) { |
| 1655 | pnetwork = container_of(plist, struct wlan_network, list); |
| 1656 | if (!pnetwork) { |
| 1657 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 2febc867 | 2014-06-09 15:16:47 +0200 | [diff] [blame] | 1658 | ("%s: return _FAIL:(pnetwork == NULL)\n", |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1659 | __func__)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1660 | goto exit; |
| 1661 | } |
| 1662 | |
| 1663 | rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork); |
| 1664 | } |
| 1665 | |
Jes Sorensen | 0e634a0 | 2014-06-09 15:16:49 +0200 | [diff] [blame] | 1666 | exit: |
| 1667 | spin_unlock_bh(&pmlmepriv->scanned_queue.lock); |
| 1668 | return candidate; |
| 1669 | } |
| 1670 | |
Jes Sorensen | b66dad2 | 2014-06-09 15:16:50 +0200 | [diff] [blame] | 1671 | |
Jes Sorensen | fcc6020 | 2014-06-09 15:16:53 +0200 | [diff] [blame] | 1672 | int rtw_do_join_adhoc(struct rtw_adapter *adapter) |
| 1673 | { |
| 1674 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
| 1675 | struct wlan_bssid_ex *pdev_network; |
| 1676 | u8 *ibss; |
| 1677 | int ret; |
| 1678 | |
| 1679 | pdev_network = &adapter->registrypriv.dev_network; |
| 1680 | ibss = adapter->registrypriv.dev_network.MacAddress; |
| 1681 | |
| 1682 | _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); |
| 1683 | |
| 1684 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 1685 | ("switching to adhoc master\n")); |
| 1686 | |
| 1687 | memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, |
| 1688 | sizeof(struct cfg80211_ssid)); |
| 1689 | |
| 1690 | rtw_update_registrypriv_dev_network23a(adapter); |
| 1691 | rtw_generate_random_ibss23a(ibss); |
| 1692 | |
| 1693 | pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; |
| 1694 | |
| 1695 | ret = rtw_createbss_cmd23a(adapter); |
| 1696 | if (ret != _SUCCESS) { |
| 1697 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 1698 | ("Error =>rtw_createbss_cmd23a status FAIL\n")); |
| 1699 | } else { |
| 1700 | pmlmepriv->to_join = false; |
| 1701 | } |
| 1702 | |
| 1703 | return ret; |
| 1704 | } |
| 1705 | |
Jes Sorensen | b66dad2 | 2014-06-09 15:16:50 +0200 | [diff] [blame] | 1706 | int rtw_do_join_network(struct rtw_adapter *adapter, |
| 1707 | struct wlan_network *candidate) |
| 1708 | { |
| 1709 | int ret; |
| 1710 | |
| 1711 | /* check for situation of _FW_LINKED */ |
| 1712 | if (check_fwstate(&adapter->mlmepriv, _FW_LINKED)) { |
| 1713 | DBG_8723A("%s: _FW_LINKED while ask_for_joinbss!\n", __func__); |
| 1714 | |
| 1715 | rtw_disassoc_cmd23a(adapter, 0, true); |
| 1716 | rtw_indicate_disconnect23a(adapter); |
| 1717 | rtw_free_assoc_resources23a(adapter, 0); |
| 1718 | } |
| 1719 | set_fwstate(&adapter->mlmepriv, _FW_UNDER_LINKING); |
| 1720 | |
| 1721 | ret = rtw_joinbss_cmd23a(adapter, candidate); |
| 1722 | |
| 1723 | if (ret == _SUCCESS) |
| 1724 | mod_timer(&adapter->mlmepriv.assoc_timer, |
| 1725 | jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); |
| 1726 | |
| 1727 | return ret; |
| 1728 | } |
| 1729 | |
Jes Sorensen | 0e634a0 | 2014-06-09 15:16:49 +0200 | [diff] [blame] | 1730 | int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv) |
| 1731 | { |
| 1732 | struct rtw_adapter *adapter; |
| 1733 | struct wlan_network *candidate = NULL; |
| 1734 | int ret; |
| 1735 | |
| 1736 | adapter = pmlmepriv->nic_hdl; |
| 1737 | |
| 1738 | candidate = rtw_select_candidate_from_queue(pmlmepriv); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1739 | if (!candidate) { |
| 1740 | DBG_8723A("%s: return _FAIL(candidate == NULL)\n", __func__); |
| 1741 | ret = _FAIL; |
| 1742 | goto exit; |
| 1743 | } else { |
| 1744 | DBG_8723A("%s: candidate: %s("MAC_FMT", ch:%u)\n", __func__, |
| 1745 | candidate->network.Ssid.ssid, |
| 1746 | MAC_ARG(candidate->network.MacAddress), |
Jes Sorensen | 37cb982 | 2014-05-21 09:37:40 +0200 | [diff] [blame] | 1747 | candidate->network.DSConfig); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1748 | } |
| 1749 | |
Jes Sorensen | b66dad2 | 2014-06-09 15:16:50 +0200 | [diff] [blame] | 1750 | ret = rtw_do_join_network(adapter, candidate); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1751 | |
| 1752 | exit: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1753 | return ret; |
| 1754 | } |
| 1755 | |
Greg Donald | 8e3d161 | 2014-10-02 18:28:41 -0500 | [diff] [blame] | 1756 | int rtw_set_auth23a(struct rtw_adapter *adapter, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1757 | struct security_priv *psecuritypriv) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1758 | { |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 1759 | struct cmd_obj *pcmd; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1760 | struct setauth_parm *psetauthparm; |
| 1761 | struct cmd_priv *pcmdpriv = &adapter->cmdpriv; |
| 1762 | int res = _SUCCESS; |
| 1763 | |
Sachin Kamat | db5767a | 2014-05-29 17:05:19 +0530 | [diff] [blame] | 1764 | pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1765 | if (!pcmd) { |
| 1766 | res = _FAIL; /* try again */ |
| 1767 | goto exit; |
| 1768 | } |
| 1769 | |
Sachin Kamat | 47b0c98 | 2014-05-28 17:36:24 +0530 | [diff] [blame] | 1770 | psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_KERNEL); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1771 | if (!psetauthparm) { |
| 1772 | kfree(pcmd); |
| 1773 | res = _FAIL; |
| 1774 | goto exit; |
| 1775 | } |
| 1776 | |
| 1777 | psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm; |
| 1778 | |
| 1779 | pcmd->cmdcode = _SetAuth_CMD_; |
| 1780 | pcmd->parmbuf = (unsigned char *)psetauthparm; |
| 1781 | pcmd->cmdsz = (sizeof(struct setauth_parm)); |
| 1782 | pcmd->rsp = NULL; |
| 1783 | pcmd->rspsz = 0; |
| 1784 | |
Greg Donald | c895a5d | 2014-09-16 18:37:41 -0500 | [diff] [blame] | 1785 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1786 | ("after enqueue set_auth_cmd, auth_mode=%x\n", |
| 1787 | psecuritypriv->dot11AuthAlgrthm)); |
| 1788 | |
| 1789 | res = rtw_enqueue_cmd23a(pcmdpriv, pcmd); |
| 1790 | |
| 1791 | exit: |
| 1792 | |
| 1793 | return res; |
| 1794 | } |
| 1795 | |
| 1796 | int rtw_set_key23a(struct rtw_adapter *adapter, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1797 | struct security_priv *psecuritypriv, int keyid, u8 set_tx) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1798 | { |
| 1799 | u8 keylen; |
| 1800 | struct cmd_obj *pcmd; |
| 1801 | struct setkey_parm *psetkeyparm; |
| 1802 | struct cmd_priv *pcmdpriv = &adapter->cmdpriv; |
| 1803 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
| 1804 | int res = _SUCCESS; |
| 1805 | |
Jes Sorensen | 4e489d9 | 2014-05-09 15:04:16 +0200 | [diff] [blame] | 1806 | if (keyid >= 4) { |
| 1807 | res = _FAIL; |
| 1808 | goto exit; |
| 1809 | } |
| 1810 | |
Sachin Kamat | 47b0c98 | 2014-05-28 17:36:24 +0530 | [diff] [blame] | 1811 | pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1812 | if (!pcmd) { |
| 1813 | res = _FAIL; /* try again */ |
| 1814 | goto exit; |
| 1815 | } |
Larry Finger | c17416e | 2014-03-28 21:37:42 -0500 | [diff] [blame] | 1816 | psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1817 | if (!psetkeyparm) { |
| 1818 | kfree(pcmd); |
| 1819 | res = _FAIL; |
| 1820 | goto exit; |
| 1821 | } |
| 1822 | |
| 1823 | if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { |
| 1824 | psetkeyparm->algorithm = (unsigned char) |
| 1825 | psecuritypriv->dot118021XGrpPrivacy; |
| 1826 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1827 | ("\n rtw_set_key23a: psetkeyparm->algorithm = " |
| 1828 | "(unsigned char)psecuritypriv->dot118021XGrpPrivacy " |
| 1829 | "=%d\n", psetkeyparm->algorithm)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1830 | } else { |
| 1831 | psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm; |
| 1832 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 1833 | ("\n rtw_set_key23a: psetkeyparm->algorithm = (u8)" |
| 1834 | "psecuritypriv->dot11PrivacyAlgrthm =%d\n", |
| 1835 | psetkeyparm->algorithm)); |
| 1836 | } |
Jes Sorensen | 4e489d9 | 2014-05-09 15:04:16 +0200 | [diff] [blame] | 1837 | psetkeyparm->keyid = keyid;/* 0~3 */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1838 | psetkeyparm->set_tx = set_tx; |
| 1839 | if (is_wep_enc(psetkeyparm->algorithm)) |
Jes Sorensen | 4e489d9 | 2014-05-09 15:04:16 +0200 | [diff] [blame] | 1840 | pmlmepriv->key_mask |= BIT(psetkeyparm->keyid); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1841 | |
| 1842 | DBG_8723A("==> rtw_set_key23a algorithm(%x), keyid(%x), key_mask(%x)\n", |
| 1843 | psetkeyparm->algorithm, psetkeyparm->keyid, |
| 1844 | pmlmepriv->key_mask); |
| 1845 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
| 1846 | ("\n rtw_set_key23a: psetkeyparm->algorithm =%d psetkeyparm->" |
| 1847 | "keyid = (u8)keyid =%d\n", psetkeyparm->algorithm, keyid)); |
| 1848 | |
| 1849 | switch (psetkeyparm->algorithm) { |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 1850 | case WLAN_CIPHER_SUITE_WEP40: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1851 | keylen = 5; |
| 1852 | memcpy(&psetkeyparm->key[0], |
Jes Sorensen | e082790 | 2014-05-21 09:37:35 +0200 | [diff] [blame] | 1853 | &psecuritypriv->wep_key[keyid].key, keylen); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1854 | break; |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 1855 | case WLAN_CIPHER_SUITE_WEP104: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1856 | keylen = 13; |
| 1857 | memcpy(&psetkeyparm->key[0], |
Jes Sorensen | e082790 | 2014-05-21 09:37:35 +0200 | [diff] [blame] | 1858 | &psecuritypriv->wep_key[keyid].key, keylen); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1859 | break; |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 1860 | case WLAN_CIPHER_SUITE_TKIP: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1861 | keylen = 16; |
| 1862 | memcpy(&psetkeyparm->key, |
| 1863 | &psecuritypriv->dot118021XGrpKey[keyid], keylen); |
| 1864 | psetkeyparm->grpkey = 1; |
| 1865 | break; |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 1866 | case WLAN_CIPHER_SUITE_CCMP: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1867 | keylen = 16; |
| 1868 | memcpy(&psetkeyparm->key, |
| 1869 | &psecuritypriv->dot118021XGrpKey[keyid], keylen); |
| 1870 | psetkeyparm->grpkey = 1; |
| 1871 | break; |
| 1872 | default: |
| 1873 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1874 | ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm" |
| 1875 | " = %x (must be 1 or 2 or 4 or 5)\n", |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1876 | psecuritypriv->dot11PrivacyAlgrthm)); |
| 1877 | res = _FAIL; |
Larry Finger | c17416e | 2014-03-28 21:37:42 -0500 | [diff] [blame] | 1878 | kfree(pcmd); |
| 1879 | kfree(psetkeyparm); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1880 | goto exit; |
| 1881 | } |
| 1882 | |
| 1883 | pcmd->cmdcode = _SetKey_CMD_; |
| 1884 | pcmd->parmbuf = (u8 *)psetkeyparm; |
| 1885 | pcmd->cmdsz = (sizeof(struct setkey_parm)); |
| 1886 | pcmd->rsp = NULL; |
| 1887 | pcmd->rspsz = 0; |
| 1888 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1889 | /* sema_init(&pcmd->cmd_sem, 0); */ |
| 1890 | |
| 1891 | res = rtw_enqueue_cmd23a(pcmdpriv, pcmd); |
| 1892 | |
| 1893 | exit: |
| 1894 | |
| 1895 | return res; |
| 1896 | } |
| 1897 | |
| 1898 | /* adjust IEs for rtw_joinbss_cmd23a in WMM */ |
| 1899 | int rtw_restruct_wmm_ie23a(struct rtw_adapter *adapter, u8 *in_ie, |
Jes Sorensen | 86184b9 | 2014-06-24 15:03:55 +0200 | [diff] [blame] | 1900 | u8 *out_ie, uint in_len, uint initial_out_len) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1901 | { |
Jes Sorensen | 86184b9 | 2014-06-24 15:03:55 +0200 | [diff] [blame] | 1902 | int ielength; |
| 1903 | const u8 *p; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1904 | |
Jes Sorensen | 86184b9 | 2014-06-24 15:03:55 +0200 | [diff] [blame] | 1905 | ielength = initial_out_len; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1906 | |
Jes Sorensen | 86184b9 | 2014-06-24 15:03:55 +0200 | [diff] [blame] | 1907 | p = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, |
| 1908 | WLAN_OUI_TYPE_MICROSOFT_WMM, |
| 1909 | in_ie, in_len); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1910 | |
Jes Sorensen | 86184b9 | 2014-06-24 15:03:55 +0200 | [diff] [blame] | 1911 | if (p && p[1]) { |
| 1912 | memcpy(out_ie + initial_out_len, p, 9); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1913 | |
Jes Sorensen | 86184b9 | 2014-06-24 15:03:55 +0200 | [diff] [blame] | 1914 | out_ie[initial_out_len + 1] = 7; |
| 1915 | out_ie[initial_out_len + 6] = 0; |
| 1916 | out_ie[initial_out_len + 8] = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1917 | |
Jes Sorensen | 86184b9 | 2014-06-24 15:03:55 +0200 | [diff] [blame] | 1918 | ielength += 9; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1919 | } |
| 1920 | |
| 1921 | return ielength; |
| 1922 | } |
| 1923 | |
| 1924 | /* */ |
| 1925 | /* Ported from 8185: IsInPreAuthKeyList(). |
| 1926 | (Renamed from SecIsInPreAuthKeyList(), 2006-10-13.) */ |
| 1927 | /* Added by Annie, 2006-05-07. */ |
| 1928 | /* */ |
| 1929 | /* Search by BSSID, */ |
| 1930 | /* Return Value: */ |
| 1931 | /* -1 :if there is no pre-auth key in the table */ |
| 1932 | /* >= 0 :if there is pre-auth key, and return the entry id */ |
| 1933 | /* */ |
| 1934 | /* */ |
| 1935 | |
| 1936 | static int SecIsInPMKIDList(struct rtw_adapter *Adapter, u8 *bssid) |
| 1937 | { |
| 1938 | struct security_priv *psecuritypriv = &Adapter->securitypriv; |
| 1939 | int i = 0; |
| 1940 | |
| 1941 | do { |
| 1942 | if (psecuritypriv->PMKIDList[i].bUsed && |
| 1943 | ether_addr_equal(psecuritypriv->PMKIDList[i].Bssid, bssid)) { |
| 1944 | break; |
| 1945 | } else { |
| 1946 | i++; |
| 1947 | /* continue; */ |
| 1948 | } |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1949 | } while (i < NUM_PMKID_CACHE); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1950 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1951 | if (i == NUM_PMKID_CACHE) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1952 | i = -1;/* Could not find. */ |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1953 | else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1954 | /* There is one Pre-Authentication Key for |
| 1955 | the specific BSSID. */ |
| 1956 | } |
| 1957 | |
| 1958 | return i; |
| 1959 | } |
| 1960 | |
| 1961 | /* */ |
| 1962 | /* Check the RSN IE length */ |
| 1963 | /* If the RSN IE length <= 20, the RSN IE didn't include |
| 1964 | the PMKID information */ |
| 1965 | /* 0-11th element in the array are the fixed IE */ |
| 1966 | /* 12th element in the array is the IE */ |
| 1967 | /* 13th element in the array is the IE length */ |
| 1968 | /* */ |
| 1969 | |
| 1970 | static int rtw_append_pmkid(struct rtw_adapter *Adapter, int iEntry, |
| 1971 | u8 *ie, uint ie_len) |
| 1972 | { |
| 1973 | struct security_priv *psecuritypriv = &Adapter->securitypriv; |
| 1974 | |
Jes Sorensen | 98f979f | 2014-06-24 15:03:56 +0200 | [diff] [blame] | 1975 | if (ie[1] <= 20) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1976 | /* The RSN IE didn't include the PMK ID, |
| 1977 | append the PMK information */ |
| 1978 | ie[ie_len] = 1; |
| 1979 | ie_len++; |
| 1980 | ie[ie_len] = 0; /* PMKID count = 0x0100 */ |
| 1981 | ie_len++; |
| 1982 | memcpy(&ie[ie_len], |
| 1983 | &psecuritypriv->PMKIDList[iEntry].PMKID, 16); |
| 1984 | |
| 1985 | ie_len += 16; |
Jes Sorensen | 98f979f | 2014-06-24 15:03:56 +0200 | [diff] [blame] | 1986 | ie[1] += 18;/* PMKID length = 2+16 */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1987 | } |
| 1988 | return ie_len; |
| 1989 | } |
Jes Sorensen | 814a1d9 | 2014-04-09 23:21:06 +0200 | [diff] [blame] | 1990 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1991 | int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 1992 | uint in_len) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1993 | { |
| 1994 | u8 authmode; |
| 1995 | uint ielength; |
| 1996 | int iEntry; |
| 1997 | struct mlme_priv *pmlmepriv = &adapter->mlmepriv; |
| 1998 | struct security_priv *psecuritypriv = &adapter->securitypriv; |
| 1999 | uint ndisauthmode = psecuritypriv->ndisauthtype; |
| 2000 | uint ndissecuritytype = psecuritypriv->ndisencryptstatus; |
| 2001 | |
| 2002 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2003 | ("+rtw_restruct_sec_ie23a: ndisauthmode=%d " |
| 2004 | "ndissecuritytype=%d\n", ndisauthmode, ndissecuritytype)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2005 | |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 2006 | ielength = 0; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2007 | if (ndisauthmode == Ndis802_11AuthModeWPA || |
| 2008 | ndisauthmode == Ndis802_11AuthModeWPAPSK) |
Jes Sorensen | 9300c94 | 2014-04-15 19:43:21 +0200 | [diff] [blame] | 2009 | authmode = WLAN_EID_VENDOR_SPECIFIC; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2010 | if (ndisauthmode == Ndis802_11AuthModeWPA2 || |
| 2011 | ndisauthmode == Ndis802_11AuthModeWPA2PSK) |
Jes Sorensen | a131aac | 2014-06-21 16:50:15 +0200 | [diff] [blame] | 2012 | authmode = WLAN_EID_RSN; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2013 | |
| 2014 | if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { |
| 2015 | memcpy(out_ie + ielength, psecuritypriv->wps_ie, |
| 2016 | psecuritypriv->wps_ie_len); |
| 2017 | |
| 2018 | ielength += psecuritypriv->wps_ie_len; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2019 | } else if (authmode == WLAN_EID_VENDOR_SPECIFIC || |
Jes Sorensen | a131aac | 2014-06-21 16:50:15 +0200 | [diff] [blame] | 2020 | authmode == WLAN_EID_RSN) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2021 | /* copy RSN or SSN */ |
| 2022 | memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], |
| 2023 | psecuritypriv->supplicant_ie[1] + 2); |
| 2024 | ielength += psecuritypriv->supplicant_ie[1] + 2; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2025 | } |
| 2026 | |
| 2027 | iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2028 | if (iEntry < 0) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2029 | return ielength; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2030 | else { |
Jes Sorensen | a131aac | 2014-06-21 16:50:15 +0200 | [diff] [blame] | 2031 | if (authmode == WLAN_EID_RSN) |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2032 | ielength = rtw_append_pmkid(adapter, iEntry, |
| 2033 | out_ie, ielength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2034 | } |
| 2035 | |
| 2036 | return ielength; |
| 2037 | } |
| 2038 | |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 2039 | void rtw_init_registrypriv_dev_network23a(struct rtw_adapter *adapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2040 | { |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 2041 | struct registry_priv *pregistrypriv = &adapter->registrypriv; |
| 2042 | struct eeprom_priv *peepriv = &adapter->eeprompriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2043 | struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; |
| 2044 | u8 *myhwaddr = myid(peepriv); |
| 2045 | |
| 2046 | ether_addr_copy(pdev_network->MacAddress, myhwaddr); |
| 2047 | |
| 2048 | memcpy(&pdev_network->Ssid, &pregistrypriv->ssid, |
| 2049 | sizeof(struct cfg80211_ssid)); |
| 2050 | |
Jes Sorensen | 143ced2 | 2014-06-19 11:37:22 +0200 | [diff] [blame] | 2051 | pdev_network->beacon_interval = 100; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2052 | } |
| 2053 | |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 2054 | void rtw_update_registrypriv_dev_network23a(struct rtw_adapter *adapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2055 | { |
| 2056 | int sz = 0; |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 2057 | struct registry_priv *pregistrypriv = &adapter->registrypriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2058 | struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; |
| 2059 | struct security_priv *psecuritypriv = &adapter->securitypriv; |
| 2060 | struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; |
| 2061 | /* struct xmit_priv *pxmitpriv = &adapter->xmitpriv; */ |
| 2062 | |
| 2063 | pdev_network->Privacy = |
| 2064 | (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0); |
| 2065 | |
| 2066 | pdev_network->Rssi = 0; |
| 2067 | |
Jes Sorensen | 37cb982 | 2014-05-21 09:37:40 +0200 | [diff] [blame] | 2068 | pdev_network->DSConfig = pregistrypriv->channel; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2069 | RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, |
Jes Sorensen | 37cb982 | 2014-05-21 09:37:40 +0200 | [diff] [blame] | 2070 | ("pregistrypriv->channel =%d, pdev_network->DSConfig = 0x%x\n", |
| 2071 | pregistrypriv->channel, pdev_network->DSConfig)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2072 | |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 2073 | if (cur_network->network.ifmode == NL80211_IFTYPE_ADHOC) |
Jes Sorensen | 37cb982 | 2014-05-21 09:37:40 +0200 | [diff] [blame] | 2074 | pdev_network->ATIMWindow = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2075 | |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 2076 | pdev_network->ifmode = cur_network->network.ifmode; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2077 | |
| 2078 | /* 1. Supported rates */ |
| 2079 | /* 2. IE */ |
| 2080 | |
| 2081 | sz = rtw_generate_ie23a(pregistrypriv); |
| 2082 | |
| 2083 | pdev_network->IELength = sz; |
| 2084 | |
| 2085 | pdev_network->Length = |
Jes Sorensen | 5201795 | 2014-04-26 18:55:09 +0200 | [diff] [blame] | 2086 | get_wlan_bssid_ex_sz(pdev_network); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2087 | |
| 2088 | /* notes: translate IELength & Length after assign the |
| 2089 | Length to cmdsz in createbss_cmd(); */ |
| 2090 | /* pdev_network->IELength = cpu_to_le32(sz); */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2091 | } |
| 2092 | |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 2093 | /* the function is at passive_level */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2094 | void rtw_joinbss_reset23a(struct rtw_adapter *padapter) |
| 2095 | { |
| 2096 | u8 threshold; |
| 2097 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 2098 | struct ht_priv *phtpriv = &pmlmepriv->htpriv; |
| 2099 | |
| 2100 | /* todo: if you want to do something io/reg/hw setting |
| 2101 | before join_bss, please add code here */ |
| 2102 | |
| 2103 | pmlmepriv->num_FortyMHzIntolerant = 0; |
| 2104 | |
| 2105 | pmlmepriv->num_sta_no_ht = 0; |
| 2106 | |
| 2107 | phtpriv->ampdu_enable = false;/* reset to disabled */ |
| 2108 | |
| 2109 | /* TH = 1 => means that invalidate usb rx aggregation */ |
| 2110 | /* TH = 0 => means that validate usb rx aggregation, use init value. */ |
| 2111 | if (phtpriv->ht_option) { |
| 2112 | if (padapter->registrypriv.wifi_spec == 1) |
| 2113 | threshold = 1; |
| 2114 | else |
| 2115 | threshold = 0; |
Jes Sorensen | 1e7b6eb | 2014-04-09 23:20:36 +0200 | [diff] [blame] | 2116 | } else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2117 | threshold = 1; |
Jes Sorensen | 1e7b6eb | 2014-04-09 23:20:36 +0200 | [diff] [blame] | 2118 | |
| 2119 | rtl8723a_set_rxdma_agg_pg_th(padapter, threshold); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2120 | } |
| 2121 | |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 2122 | /* the function is >= passive_level */ |
Jes Sorensen | 6f765c2 | 2014-06-09 15:16:06 +0200 | [diff] [blame] | 2123 | bool rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, |
| 2124 | u8 *out_ie, uint in_len, uint *pout_len) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2125 | { |
Jes Sorensen | 7c2f97b | 2014-04-15 19:43:37 +0200 | [diff] [blame] | 2126 | u32 out_len; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2127 | int max_rx_ampdu_factor; |
Jes Sorensen | 7c2f97b | 2014-04-15 19:43:37 +0200 | [diff] [blame] | 2128 | unsigned char *pframe; |
| 2129 | const u8 *p; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2130 | struct ieee80211_ht_cap ht_capie; |
Jes Sorensen | c9324c8 | 2014-06-09 15:16:05 +0200 | [diff] [blame] | 2131 | u8 WMM_IE[7] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2132 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2133 | struct ht_priv *phtpriv = &pmlmepriv->htpriv; |
| 2134 | |
| 2135 | phtpriv->ht_option = false; |
| 2136 | |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 2137 | p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, in_ie, in_len); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2138 | |
Jes Sorensen | 7c2f97b | 2014-04-15 19:43:37 +0200 | [diff] [blame] | 2139 | if (p && p[1] > 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2140 | u32 rx_packet_offset, max_recvbuf_sz; |
Yeliz Taneroglu | 29ed932 | 2014-10-09 01:22:14 +0300 | [diff] [blame] | 2141 | |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 2142 | if (pmlmepriv->qos_option == 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2143 | out_len = *pout_len; |
| 2144 | pframe = rtw_set_ie23a(out_ie + out_len, |
Jes Sorensen | c9324c8 | 2014-06-09 15:16:05 +0200 | [diff] [blame] | 2145 | WLAN_EID_VENDOR_SPECIFIC, |
| 2146 | sizeof(WMM_IE), WMM_IE, |
| 2147 | pout_len); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2148 | |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 2149 | pmlmepriv->qos_option = 1; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2150 | } |
| 2151 | |
| 2152 | out_len = *pout_len; |
| 2153 | |
| 2154 | memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap)); |
| 2155 | |
Kinka Huang | ce6bed6 | 2014-11-20 00:27:02 +0800 | [diff] [blame^] | 2156 | ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2157 | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | |
Kinka Huang | ce6bed6 | 2014-11-20 00:27:02 +0800 | [diff] [blame^] | 2158 | IEEE80211_HT_CAP_TX_STBC | IEEE80211_HT_CAP_DSSSCCK40); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2159 | |
Jes Sorensen | 39f1a8e | 2014-05-16 10:04:20 +0200 | [diff] [blame] | 2160 | GetHalDefVar8192CUsb(padapter, HAL_DEF_RX_PACKET_OFFSET, |
| 2161 | &rx_packet_offset); |
| 2162 | GetHalDefVar8192CUsb(padapter, HAL_DEF_MAX_RECVBUF_SZ, |
| 2163 | &max_recvbuf_sz); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2164 | |
Jes Sorensen | 39f1a8e | 2014-05-16 10:04:20 +0200 | [diff] [blame] | 2165 | GetHalDefVar8192CUsb(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, |
| 2166 | &max_rx_ampdu_factor); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2167 | ht_capie.ampdu_params_info = max_rx_ampdu_factor & 0x03; |
| 2168 | |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 2169 | if (padapter->securitypriv.dot11PrivacyAlgrthm == |
| 2170 | WLAN_CIPHER_SUITE_CCMP) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2171 | ht_capie.ampdu_params_info |= |
| 2172 | (IEEE80211_HT_AMPDU_PARM_DENSITY& (0x07 << 2)); |
| 2173 | else |
| 2174 | ht_capie.ampdu_params_info |= |
| 2175 | (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); |
| 2176 | |
Jes Sorensen | a7eab38 | 2014-04-15 19:43:25 +0200 | [diff] [blame] | 2177 | pframe = rtw_set_ie23a(out_ie + out_len, WLAN_EID_HT_CAPABILITY, |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2178 | sizeof(struct ieee80211_ht_cap), |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 2179 | (unsigned char *)&ht_capie, pout_len); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2180 | |
| 2181 | phtpriv->ht_option = true; |
| 2182 | |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 2183 | p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, in_ie, in_len); |
Jes Sorensen | 6594c96 | 2014-05-31 18:05:12 +0200 | [diff] [blame] | 2184 | if (p && (p[1] == sizeof(struct ieee80211_ht_operation))) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2185 | out_len = *pout_len; |
Jes Sorensen | a7eab38 | 2014-04-15 19:43:25 +0200 | [diff] [blame] | 2186 | pframe = rtw_set_ie23a(out_ie + out_len, |
| 2187 | WLAN_EID_HT_OPERATION, |
Jes Sorensen | 7c2f97b | 2014-04-15 19:43:37 +0200 | [diff] [blame] | 2188 | p[1], p + 2 , pout_len); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2189 | } |
| 2190 | } |
| 2191 | |
| 2192 | return phtpriv->ht_option; |
| 2193 | } |
| 2194 | |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 2195 | /* the function is > passive_level (in critical_section) */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2196 | void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) |
| 2197 | { |
Jes Sorensen | 2403ea6 | 2014-04-15 19:43:38 +0200 | [diff] [blame] | 2198 | u8 max_ampdu_sz; |
| 2199 | const u8 *p; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2200 | struct ieee80211_ht_cap *pht_capie; |
Jes Sorensen | 6594c96 | 2014-05-31 18:05:12 +0200 | [diff] [blame] | 2201 | struct ieee80211_ht_operation *pht_addtinfo; |
Jes Sorensen | 2403ea6 | 2014-04-15 19:43:38 +0200 | [diff] [blame] | 2202 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 2203 | struct ht_priv *phtpriv = &pmlmepriv->htpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2204 | struct registry_priv *pregistrypriv = &padapter->registrypriv; |
Jes Sorensen | 2403ea6 | 2014-04-15 19:43:38 +0200 | [diff] [blame] | 2205 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2206 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 2207 | |
| 2208 | if (!phtpriv->ht_option) |
| 2209 | return; |
| 2210 | |
| 2211 | if ((!pmlmeinfo->HT_info_enable) || (!pmlmeinfo->HT_caps_enable)) |
| 2212 | return; |
| 2213 | |
| 2214 | DBG_8723A("+rtw_update_ht_cap23a()\n"); |
| 2215 | |
| 2216 | /* maybe needs check if ap supports rx ampdu. */ |
Jes Sorensen | 47e5d2f | 2014-06-09 15:16:08 +0200 | [diff] [blame] | 2217 | if (!phtpriv->ampdu_enable && pregistrypriv->ampdu_enable == 1) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2218 | if (pregistrypriv->wifi_spec == 1) |
| 2219 | phtpriv->ampdu_enable = false; |
| 2220 | else |
| 2221 | phtpriv->ampdu_enable = true; |
Jes Sorensen | 2403ea6 | 2014-04-15 19:43:38 +0200 | [diff] [blame] | 2222 | } else if (pregistrypriv->ampdu_enable == 2) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2223 | phtpriv->ampdu_enable = true; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2224 | |
| 2225 | /* check Max Rx A-MPDU Size */ |
Jes Sorensen | 2403ea6 | 2014-04-15 19:43:38 +0200 | [diff] [blame] | 2226 | p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pie, ie_len); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2227 | |
Jes Sorensen | 2403ea6 | 2014-04-15 19:43:38 +0200 | [diff] [blame] | 2228 | if (p && p[1] > 0) { |
| 2229 | pht_capie = (struct ieee80211_ht_cap *)(p + 2); |
| 2230 | max_ampdu_sz = pht_capie->ampdu_params_info & |
| 2231 | IEEE80211_HT_AMPDU_PARM_FACTOR; |
| 2232 | /* max_ampdu_sz (kbytes); */ |
| 2233 | max_ampdu_sz = 1 << (max_ampdu_sz + 3); |
| 2234 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2235 | phtpriv->rx_ampdu_maxlen = max_ampdu_sz; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2236 | } |
| 2237 | |
Jes Sorensen | 2403ea6 | 2014-04-15 19:43:38 +0200 | [diff] [blame] | 2238 | p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, ie_len); |
| 2239 | if (p && p[1] > 0) { |
Jes Sorensen | 6594c96 | 2014-05-31 18:05:12 +0200 | [diff] [blame] | 2240 | pht_addtinfo = (struct ieee80211_ht_operation *)(p + 2); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2241 | /* todo: */ |
| 2242 | } |
| 2243 | |
| 2244 | /* update cur_bwmode & cur_ch_offset */ |
Jes Sorensen | 2403ea6 | 2014-04-15 19:43:38 +0200 | [diff] [blame] | 2245 | if (pregistrypriv->cbw40_enable && |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 2246 | pmlmeinfo->ht_cap.cap_info & |
| 2247 | cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40) && |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 2248 | pmlmeinfo->HT_info.ht_param & IEEE80211_HT_PARAM_CHAN_WIDTH_ANY) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2249 | int i; |
Jes Sorensen | c2370e8 | 2014-04-09 23:20:53 +0200 | [diff] [blame] | 2250 | u8 rf_type; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2251 | |
Jes Sorensen | c2370e8 | 2014-04-09 23:20:53 +0200 | [diff] [blame] | 2252 | rf_type = rtl8723a_get_rf_type(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2253 | |
| 2254 | /* update the MCS rates */ |
Jes Sorensen | 198e95d | 2014-05-31 18:05:10 +0200 | [diff] [blame] | 2255 | for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) { |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2256 | if (rf_type == RF_1T1R || rf_type == RF_1T2R) |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 2257 | pmlmeinfo->ht_cap.mcs.rx_mask[i] &= |
| 2258 | MCS_rate_1R23A[i]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2259 | else |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 2260 | pmlmeinfo->ht_cap.mcs.rx_mask[i] &= |
| 2261 | MCS_rate_2R23A[i]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2262 | } |
Masanari Iida | 7c17d2d | 2014-07-22 23:42:24 +0900 | [diff] [blame] | 2263 | /* switch to the 40M Hz mode according to the AP */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2264 | pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40; |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 2265 | switch (pmlmeinfo->HT_info.ht_param & |
Jes Sorensen | b277541 | 2014-06-03 23:41:22 +0200 | [diff] [blame] | 2266 | IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 2267 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 2268 | pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; |
| 2269 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2270 | |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 2271 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 2272 | pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; |
| 2273 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2274 | |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 2275 | default: |
| 2276 | pmlmeext->cur_ch_offset = |
| 2277 | HAL_PRIME_CHNL_OFFSET_DONT_CARE; |
| 2278 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2279 | } |
| 2280 | } |
| 2281 | |
| 2282 | /* */ |
| 2283 | /* Config SM Power Save setting */ |
| 2284 | /* */ |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 2285 | pmlmeinfo->SM_PS = |
| 2286 | (le16_to_cpu(pmlmeinfo->ht_cap.cap_info) & |
| 2287 | IEEE80211_HT_CAP_SM_PS) >> IEEE80211_HT_CAP_SM_PS_SHIFT; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2288 | if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) |
| 2289 | DBG_8723A("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); |
| 2290 | |
| 2291 | /* */ |
| 2292 | /* Config current HT Protection mode. */ |
| 2293 | /* */ |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 2294 | pmlmeinfo->HT_protection = |
| 2295 | le16_to_cpu(pmlmeinfo->HT_info.operation_mode) & |
| 2296 | IEEE80211_HT_OP_MODE_PROTECTION; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2297 | } |
| 2298 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2299 | void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, |
| 2300 | struct xmit_frame *pxmitframe) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2301 | { |
| 2302 | u8 issued; |
| 2303 | int priority; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2304 | struct sta_info *psta; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2305 | struct ht_priv *phtpriv; |
| 2306 | struct pkt_attrib *pattrib = &pxmitframe->attrib; |
| 2307 | s32 bmcst = is_multicast_ether_addr(pattrib->ra); |
| 2308 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2309 | if (bmcst || padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2310 | return; |
| 2311 | |
| 2312 | priority = pattrib->priority; |
| 2313 | |
| 2314 | if (pattrib->psta) |
| 2315 | psta = pattrib->psta; |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2316 | else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2317 | DBG_8723A("%s, call rtw_get_stainfo23a()\n", __func__); |
| 2318 | psta = rtw_get_stainfo23a(&padapter->stapriv, pattrib->ra); |
| 2319 | } |
| 2320 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2321 | if (!psta) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2322 | DBG_8723A("%s, psta == NUL\n", __func__); |
| 2323 | return; |
| 2324 | } |
| 2325 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2326 | if (!(psta->state &_FW_LINKED)) { |
| 2327 | DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", |
| 2328 | __func__, psta->state); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2329 | return; |
| 2330 | } |
| 2331 | |
| 2332 | phtpriv = &psta->htpriv; |
| 2333 | |
Jes Sorensen | 47e5d2f | 2014-06-09 15:16:08 +0200 | [diff] [blame] | 2334 | if (phtpriv->ht_option && phtpriv->ampdu_enable) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2335 | issued = (phtpriv->agg_enable_bitmap>>priority)&0x1; |
| 2336 | issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1; |
| 2337 | |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2338 | if (issued == 0) { |
| 2339 | DBG_8723A("rtw_issue_addbareq_cmd23a, p =%d\n", |
| 2340 | priority); |
Jes Sorensen | 561fb40 | 2014-05-09 15:04:20 +0200 | [diff] [blame] | 2341 | psta->htpriv.candidate_tid_bitmap |= BIT(priority); |
Jes Sorensen | 480c865 | 2014-04-15 19:44:45 +0200 | [diff] [blame] | 2342 | rtw_addbareq_cmd23a(padapter, (u8) priority, |
| 2343 | pattrib->ra); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2344 | } |
| 2345 | } |
| 2346 | } |
| 2347 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2348 | int rtw_linked_check(struct rtw_adapter *padapter) |
| 2349 | { |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 2350 | if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) || |
| 2351 | check_fwstate(&padapter->mlmepriv, |
| 2352 | WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2353 | if (padapter->stapriv.asoc_sta_count > 2) |
| 2354 | return true; |
| 2355 | } else { /* Station mode */ |
Jes Sorensen | 5682879 | 2014-04-15 19:44:46 +0200 | [diff] [blame] | 2356 | if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 2357 | return true; |
| 2358 | } |
| 2359 | return false; |
| 2360 | } |