Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2007 - 2012 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_AP_C_ |
| 16 | |
| 17 | #include <osdep_service.h> |
| 18 | #include <drv_types.h> |
| 19 | #include <linux/ieee80211.h> |
| 20 | #include <wifi.h> |
Jes Sorensen | 1ec6934 | 2014-05-16 10:04:11 +0200 | [diff] [blame] | 21 | #include <rtl8723a_cmd.h> |
Jes Sorensen | dbe9849 | 2014-05-16 10:04:13 +0200 | [diff] [blame] | 22 | #include <rtl8723a_hal.h> |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 23 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 24 | extern unsigned char WMM_OUI23A[]; |
| 25 | extern unsigned char WPS_OUI23A[]; |
| 26 | extern unsigned char P2P_OUI23A[]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 27 | |
| 28 | void init_mlme_ap_info23a(struct rtw_adapter *padapter) |
| 29 | { |
| 30 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 31 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 32 | struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; |
| 33 | |
| 34 | spin_lock_init(&pmlmepriv->bcn_update_lock); |
| 35 | |
| 36 | /* for ACL */ |
| 37 | _rtw_init_queue23a(&pacl_list->acl_node_q); |
| 38 | |
| 39 | start_ap_mode23a(padapter); |
| 40 | } |
| 41 | |
| 42 | void free_mlme_ap_info23a(struct rtw_adapter *padapter) |
| 43 | { |
| 44 | struct sta_info *psta = NULL; |
| 45 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 46 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 47 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 48 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 49 | |
| 50 | pmlmepriv->update_bcn = false; |
| 51 | pmlmeext->bstart_bss = false; |
| 52 | |
| 53 | rtw_sta_flush23a(padapter); |
| 54 | |
Jes Sorensen | 6ec2627 | 2014-07-17 22:59:46 +0200 | [diff] [blame] | 55 | pmlmeinfo->state = MSR_NOLINK; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 56 | |
| 57 | /* free_assoc_sta_resources */ |
| 58 | rtw_free_all_stainfo23a(padapter); |
| 59 | |
| 60 | /* free bc/mc sta_info */ |
| 61 | psta = rtw_get_bcmc_stainfo23a(padapter); |
| 62 | spin_lock_bh(&pstapriv->sta_hash_lock); |
| 63 | rtw_free_stainfo23a(padapter, psta); |
| 64 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 65 | } |
| 66 | |
| 67 | static void update_BCNTIM(struct rtw_adapter *padapter) |
| 68 | { |
| 69 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 70 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 71 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 72 | struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; |
| 73 | unsigned char *pie = pnetwork_mlmeext->IEs; |
| 74 | u8 *p, *dst_ie, *premainder_ie = NULL, *pbackup_remainder_ie = NULL; |
Larry Finger | a96ae6f | 2014-04-26 18:55:18 +0200 | [diff] [blame] | 75 | __le16 tim_bitmap_le; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 76 | uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen; |
| 77 | |
| 78 | tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap); |
| 79 | |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 80 | p = rtw_get_ie23a(pie, WLAN_EID_TIM, &tim_ielen, |
| 81 | pnetwork_mlmeext->IELength); |
MihaelaGaman | adabff8 | 2014-09-14 12:56:43 +0300 | [diff] [blame] | 82 | if (p != NULL && tim_ielen > 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 83 | tim_ielen += 2; |
| 84 | |
| 85 | premainder_ie = p+tim_ielen; |
| 86 | |
Tapasweni Pathak | 7d36429 | 2014-09-21 19:38:30 +0530 | [diff] [blame] | 87 | tim_ie_offset = (int)(p - pie); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 88 | |
| 89 | remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen; |
| 90 | |
| 91 | /* append TIM IE from dst_ie offset */ |
| 92 | dst_ie = p; |
| 93 | } else { |
| 94 | tim_ielen = 0; |
| 95 | |
Masanari Iida | 96b0a5b | 2014-07-22 23:42:45 +0900 | [diff] [blame] | 96 | /* calculate head_len */ |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 97 | offset = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 98 | |
| 99 | /* get ssid_ie len */ |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 100 | p = rtw_get_ie23a(pie, WLAN_EID_SSID, |
| 101 | &tmp_len, pnetwork_mlmeext->IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 102 | if (p != NULL) |
| 103 | offset += tmp_len+2; |
| 104 | |
| 105 | /* get supported rates len */ |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 106 | p = rtw_get_ie23a(pie, WLAN_EID_SUPP_RATES, |
| 107 | &tmp_len, pnetwork_mlmeext->IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 108 | if (p != NULL) |
| 109 | offset += tmp_len+2; |
| 110 | |
| 111 | /* DS Parameter Set IE, len = 3 */ |
| 112 | offset += 3; |
| 113 | |
| 114 | premainder_ie = pie + offset; |
| 115 | |
| 116 | remainder_ielen = pnetwork_mlmeext->IELength - offset - tim_ielen; |
| 117 | |
| 118 | /* append TIM IE from offset */ |
| 119 | dst_ie = pie + offset; |
| 120 | } |
| 121 | |
| 122 | if (remainder_ielen > 0) { |
| 123 | pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_ATOMIC); |
| 124 | if (pbackup_remainder_ie && premainder_ie) |
| 125 | memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); |
| 126 | } |
| 127 | |
MihaelaGaman | adabff8 | 2014-09-14 12:56:43 +0300 | [diff] [blame] | 128 | *dst_ie++ = WLAN_EID_TIM; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 129 | |
| 130 | if ((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc)) |
| 131 | tim_ielen = 5; |
| 132 | else |
| 133 | tim_ielen = 4; |
| 134 | |
MihaelaGaman | adabff8 | 2014-09-14 12:56:43 +0300 | [diff] [blame] | 135 | *dst_ie++ = tim_ielen; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 136 | |
MihaelaGaman | adabff8 | 2014-09-14 12:56:43 +0300 | [diff] [blame] | 137 | *dst_ie++ = 0;/* DTIM count */ |
| 138 | *dst_ie++ = 1;/* DTIM period */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 139 | |
| 140 | if (pstapriv->tim_bitmap & BIT(0))/* for bc/mc frames */ |
| 141 | *dst_ie++ = BIT(0);/* bitmap ctrl */ |
| 142 | else |
| 143 | *dst_ie++ = 0; |
| 144 | |
| 145 | if (tim_ielen == 4) { |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 146 | *dst_ie++ = *(u8 *)&tim_bitmap_le; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 147 | } else if (tim_ielen == 5) { |
| 148 | memcpy(dst_ie, &tim_bitmap_le, 2); |
MihaelaGaman | adabff8 | 2014-09-14 12:56:43 +0300 | [diff] [blame] | 149 | dst_ie += 2; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /* copy remainder IE */ |
| 153 | if (pbackup_remainder_ie) { |
| 154 | memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); |
| 155 | |
| 156 | kfree(pbackup_remainder_ie); |
| 157 | } |
| 158 | |
| 159 | offset = (uint)(dst_ie - pie); |
| 160 | pnetwork_mlmeext->IELength = offset + remainder_ielen; |
| 161 | |
| 162 | set_tx_beacon_cmd23a(padapter); |
| 163 | } |
| 164 | |
| 165 | static u8 chk_sta_is_alive(struct sta_info *psta) |
| 166 | { |
| 167 | u8 ret = false; |
| 168 | |
| 169 | if ((psta->sta_stats.last_rx_data_pkts + |
| 170 | psta->sta_stats.last_rx_ctrl_pkts) != |
| 171 | (psta->sta_stats.rx_data_pkts + psta->sta_stats.rx_ctrl_pkts)) |
| 172 | ret = true; |
| 173 | |
| 174 | sta_update_last_rx_pkts(psta); |
| 175 | |
| 176 | return ret; |
| 177 | } |
| 178 | |
| 179 | void expire_timeout_chk23a(struct rtw_adapter *padapter) |
| 180 | { |
| 181 | struct list_head *phead, *plist, *ptmp; |
| 182 | u8 updated = 0; |
| 183 | struct sta_info *psta; |
| 184 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 185 | u8 chk_alive_num = 0; |
Jes Sorensen | 6964213 | 2014-05-09 15:03:47 +0200 | [diff] [blame] | 186 | struct sta_info *chk_alive_list[NUM_STA]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 187 | int i; |
| 188 | |
| 189 | spin_lock_bh(&pstapriv->auth_list_lock); |
| 190 | |
| 191 | phead = &pstapriv->auth_list; |
| 192 | |
| 193 | /* check auth_queue */ |
| 194 | list_for_each_safe(plist, ptmp, phead) { |
| 195 | psta = container_of(plist, struct sta_info, auth_list); |
| 196 | |
MihaelaGaman | adabff8 | 2014-09-14 12:56:43 +0300 | [diff] [blame] | 197 | if (psta->expire_to > 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 198 | psta->expire_to--; |
| 199 | if (psta->expire_to == 0) { |
| 200 | list_del_init(&psta->auth_list); |
| 201 | pstapriv->auth_list_cnt--; |
| 202 | |
| 203 | DBG_8723A("auth expire %pM\n", psta->hwaddr); |
| 204 | |
| 205 | spin_unlock_bh(&pstapriv->auth_list_lock); |
| 206 | |
| 207 | spin_lock_bh(&pstapriv->sta_hash_lock); |
| 208 | rtw_free_stainfo23a(padapter, psta); |
| 209 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 210 | |
| 211 | spin_lock_bh(&pstapriv->auth_list_lock); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | } |
| 216 | |
| 217 | spin_unlock_bh(&pstapriv->auth_list_lock); |
| 218 | |
| 219 | spin_lock_bh(&pstapriv->asoc_list_lock); |
| 220 | |
| 221 | phead = &pstapriv->asoc_list; |
| 222 | |
| 223 | /* check asoc_queue */ |
| 224 | list_for_each_safe(plist, ptmp, phead) { |
| 225 | psta = container_of(plist, struct sta_info, asoc_list); |
| 226 | |
| 227 | if (chk_sta_is_alive(psta) || !psta->expire_to) { |
| 228 | psta->expire_to = pstapriv->expire_to; |
| 229 | psta->keep_alive_trycnt = 0; |
| 230 | } else { |
| 231 | psta->expire_to--; |
| 232 | } |
| 233 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 234 | if (psta->expire_to <= 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 235 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 236 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 237 | if (padapter->registrypriv.wifi_spec == 1) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 238 | psta->expire_to = pstapriv->expire_to; |
| 239 | continue; |
| 240 | } |
| 241 | |
| 242 | if (psta->state & WIFI_SLEEP_STATE) { |
| 243 | if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) { |
Masanari Iida | 96b0a5b | 2014-07-22 23:42:45 +0900 | [diff] [blame] | 244 | /* to check if alive by another methods if station is at ps mode. */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 245 | psta->expire_to = pstapriv->expire_to; |
| 246 | psta->state |= WIFI_STA_ALIVE_CHK_STATE; |
| 247 | |
| 248 | /* to update bcn with tim_bitmap for this station */ |
| 249 | pstapriv->tim_bitmap |= CHKBIT(psta->aid); |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 250 | update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 251 | |
| 252 | if (!pmlmeext->active_keep_alive_check) |
| 253 | continue; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | if (pmlmeext->active_keep_alive_check) { |
Jes Sorensen | 6964213 | 2014-05-09 15:03:47 +0200 | [diff] [blame] | 258 | chk_alive_list[chk_alive_num++] = psta; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 259 | continue; |
| 260 | } |
| 261 | |
| 262 | list_del_init(&psta->asoc_list); |
| 263 | pstapriv->asoc_list_cnt--; |
| 264 | |
| 265 | DBG_8723A("asoc expire "MAC_FMT", state = 0x%x\n", MAC_ARG(psta->hwaddr), psta->state); |
| 266 | updated = ap_free_sta23a(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING); |
| 267 | } else { |
| 268 | /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */ |
| 269 | if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt) |
| 270 | && padapter->xmitpriv.free_xmitframe_cnt < ((NR_XMITFRAME/pstapriv->asoc_list_cnt)/2) |
| 271 | ) { |
| 272 | DBG_8723A("%s sta:"MAC_FMT", sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", __func__, |
| 273 | MAC_ARG(psta->hwaddr), |
| 274 | psta->sleepq_len, |
| 275 | padapter->xmitpriv.free_xmitframe_cnt, |
| 276 | pstapriv->asoc_list_cnt); |
| 277 | wakeup_sta_to_xmit23a(padapter, psta); |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | spin_unlock_bh(&pstapriv->asoc_list_lock); |
| 283 | |
| 284 | if (chk_alive_num) { |
| 285 | |
| 286 | u8 backup_oper_channel = 0; |
| 287 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 288 | /* switch to correct channel of current network before issue keep-alive frames */ |
| 289 | if (rtw_get_oper_ch23a(padapter) != pmlmeext->cur_channel) { |
| 290 | backup_oper_channel = rtw_get_oper_ch23a(padapter); |
| 291 | SelectChannel23a(padapter, pmlmeext->cur_channel); |
Jes Sorensen | 6964213 | 2014-05-09 15:03:47 +0200 | [diff] [blame] | 292 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 293 | |
| 294 | /* issue null data to check sta alive*/ |
| 295 | for (i = 0; i < chk_alive_num; i++) { |
| 296 | |
| 297 | int ret = _FAIL; |
| 298 | |
Jes Sorensen | 6964213 | 2014-05-09 15:03:47 +0200 | [diff] [blame] | 299 | psta = chk_alive_list[i]; |
Aybuke Ozdemir | b34ba0c | 2014-09-28 17:22:36 +0300 | [diff] [blame] | 300 | if (!(psta->state & _FW_LINKED)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 301 | continue; |
| 302 | |
| 303 | if (psta->state & WIFI_SLEEP_STATE) |
| 304 | ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 1, 50); |
| 305 | else |
| 306 | ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 3, 50); |
| 307 | |
| 308 | psta->keep_alive_trycnt++; |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 309 | if (ret == _SUCCESS) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 310 | DBG_8723A("asoc check, sta(" MAC_FMT ") is alive\n", MAC_ARG(psta->hwaddr)); |
| 311 | psta->expire_to = pstapriv->expire_to; |
| 312 | psta->keep_alive_trycnt = 0; |
| 313 | continue; |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 314 | } else if (psta->keep_alive_trycnt <= 3) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 315 | DBG_8723A("ack check for asoc expire, keep_alive_trycnt =%d\n", psta->keep_alive_trycnt); |
| 316 | psta->expire_to = 1; |
| 317 | continue; |
| 318 | } |
| 319 | |
| 320 | psta->keep_alive_trycnt = 0; |
| 321 | |
| 322 | DBG_8723A("asoc expire "MAC_FMT", state = 0x%x\n", MAC_ARG(psta->hwaddr), psta->state); |
| 323 | spin_lock_bh(&pstapriv->asoc_list_lock); |
| 324 | if (!list_empty(&psta->asoc_list)) { |
| 325 | list_del_init(&psta->asoc_list); |
| 326 | pstapriv->asoc_list_cnt--; |
| 327 | updated = ap_free_sta23a(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING); |
| 328 | } |
| 329 | spin_unlock_bh(&pstapriv->asoc_list_lock); |
| 330 | |
| 331 | } |
| 332 | |
MihaelaGaman | adabff8 | 2014-09-14 12:56:43 +0300 | [diff] [blame] | 333 | if (backup_oper_channel > 0) /* back to the original operation channel */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 334 | SelectChannel23a(padapter, backup_oper_channel); |
| 335 | } |
| 336 | |
| 337 | associated_clients_update23a(padapter, updated); |
| 338 | } |
| 339 | |
| 340 | void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_level) |
| 341 | { |
| 342 | int i; |
| 343 | u8 rf_type; |
| 344 | u32 init_rate = 0; |
| 345 | unsigned char sta_band = 0, raid, shortGIrate = false; |
| 346 | unsigned char limit; |
| 347 | unsigned int tx_ra_bitmap = 0; |
| 348 | struct ht_priv *psta_ht = NULL; |
| 349 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Jes Sorensen | 5201795 | 2014-04-26 18:55:09 +0200 | [diff] [blame] | 350 | struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 351 | |
| 352 | if (psta) |
| 353 | psta_ht = &psta->htpriv; |
| 354 | else |
| 355 | return; |
| 356 | |
| 357 | if (!(psta->state & _FW_LINKED)) |
| 358 | return; |
| 359 | |
| 360 | /* b/g mode ra_bitmap */ |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 361 | for (i = 0; i < sizeof(psta->bssrateset); i++) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 362 | if (psta->bssrateset[i]) |
| 363 | tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f); |
| 364 | } |
| 365 | /* n mode ra_bitmap */ |
Jes Sorensen | c2370e8 | 2014-04-09 23:20:53 +0200 | [diff] [blame] | 366 | if (psta_ht->ht_option) { |
| 367 | rf_type = rtl8723a_get_rf_type(padapter); |
| 368 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 369 | if (rf_type == RF_2T2R) |
| 370 | limit = 16;/* 2R */ |
| 371 | else |
| 372 | limit = 8;/* 1R */ |
| 373 | |
Jes Sorensen | 5a443893 | 2014-05-09 15:04:15 +0200 | [diff] [blame] | 374 | for (i = 0; i < limit; i++) { |
| 375 | if (psta_ht->ht_cap.mcs.rx_mask[i / 8] & BIT(i % 8)) |
| 376 | tx_ra_bitmap |= BIT(i + 12); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | /* max short GI rate */ |
| 380 | shortGIrate = psta_ht->sgi; |
| 381 | } |
| 382 | |
Jes Sorensen | 37cb982 | 2014-05-21 09:37:40 +0200 | [diff] [blame] | 383 | if (pcur_network->DSConfig > 14) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 384 | /* 5G band */ |
| 385 | if (tx_ra_bitmap & 0xffff000) |
| 386 | sta_band |= WIRELESS_11_5N | WIRELESS_11A; |
| 387 | else |
| 388 | sta_band |= WIRELESS_11A; |
| 389 | } else { |
| 390 | if (tx_ra_bitmap & 0xffff000) |
| 391 | sta_band |= WIRELESS_11_24N | WIRELESS_11G | WIRELESS_11B; |
| 392 | else if (tx_ra_bitmap & 0xff0) |
Aybuke Ozdemir | dd60925 | 2014-09-28 17:22:37 +0300 | [diff] [blame] | 393 | sta_band |= WIRELESS_11G | WIRELESS_11B; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 394 | else |
| 395 | sta_band |= WIRELESS_11B; |
| 396 | } |
| 397 | |
| 398 | psta->wireless_mode = sta_band; |
| 399 | |
| 400 | raid = networktype_to_raid23a(sta_band); |
| 401 | init_rate = get_highest_rate_idx23a(tx_ra_bitmap&0x0fffffff)&0x3f; |
| 402 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 403 | if (psta->aid < NUM_STA) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 404 | u8 arg = 0; |
| 405 | |
| 406 | arg = psta->mac_id&0x1f; |
| 407 | |
| 408 | arg |= BIT(7);/* support entry 2~31 */ |
| 409 | |
| 410 | if (shortGIrate == true) |
| 411 | arg |= BIT(5); |
| 412 | |
| 413 | tx_ra_bitmap |= ((raid<<28)&0xf0000000); |
| 414 | |
| 415 | DBG_8723A("%s => mac_id:%d , raid:%d , bitmap = 0x%x, arg = " |
| 416 | "0x%x\n", |
| 417 | __func__, psta->mac_id, raid, tx_ra_bitmap, arg); |
| 418 | |
| 419 | /* bitmap[0:27] = tx_rate_bitmap */ |
| 420 | /* bitmap[28:31]= Rate Adaptive id */ |
| 421 | /* arg[0:4] = macid */ |
| 422 | /* arg[5] = Short GI */ |
Jes Sorensen | 1ec6934 | 2014-05-16 10:04:11 +0200 | [diff] [blame] | 423 | rtl8723a_add_rateatid(padapter, tx_ra_bitmap, arg, rssi_level); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 424 | |
| 425 | if (shortGIrate == true) |
| 426 | init_rate |= BIT(6); |
| 427 | |
| 428 | /* set ra_id, init_rate */ |
| 429 | psta->raid = raid; |
| 430 | psta->init_rate = init_rate; |
| 431 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 432 | } else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 433 | DBG_8723A("station aid %d exceed the max number\n", psta->aid); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | static void update_bmc_sta(struct rtw_adapter *padapter) |
| 437 | { |
| 438 | u32 init_rate = 0; |
| 439 | unsigned char network_type, raid; |
| 440 | int i, supportRateNum = 0; |
| 441 | unsigned int tx_ra_bitmap = 0; |
| 442 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Jes Sorensen | 5201795 | 2014-04-26 18:55:09 +0200 | [diff] [blame] | 443 | struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 444 | struct sta_info *psta = rtw_get_bcmc_stainfo23a(padapter); |
| 445 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 446 | if (psta) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 447 | psta->aid = 0;/* default set to 0 */ |
| 448 | psta->mac_id = psta->aid + 1; |
| 449 | |
| 450 | psta->qos_option = 0; |
| 451 | psta->htpriv.ht_option = false; |
| 452 | |
| 453 | psta->ieee8021x_blocked = 0; |
| 454 | |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 455 | memset((void *)&psta->sta_stats, 0, |
| 456 | sizeof(struct stainfo_stats)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 457 | |
| 458 | /* prepare for add_RATid23a */ |
| 459 | supportRateNum = rtw_get_rateset_len23a((u8*)&pcur_network->SupportedRates); |
| 460 | network_type = rtw_check_network_type23a((u8*)&pcur_network->SupportedRates, supportRateNum, 1); |
| 461 | |
| 462 | memcpy(psta->bssrateset, &pcur_network->SupportedRates, supportRateNum); |
| 463 | psta->bssratelen = supportRateNum; |
| 464 | |
| 465 | /* b/g mode ra_bitmap */ |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 466 | for (i = 0; i < supportRateNum; i++) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 467 | if (psta->bssrateset[i]) |
| 468 | tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f); |
| 469 | } |
| 470 | |
Jes Sorensen | 37cb982 | 2014-05-21 09:37:40 +0200 | [diff] [blame] | 471 | if (pcur_network->DSConfig > 14) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 472 | /* force to A mode. 5G doesn't support CCK rates */ |
| 473 | network_type = WIRELESS_11A; |
| 474 | tx_ra_bitmap = 0x150; /* 6, 12, 24 Mbps */ |
| 475 | } else { |
| 476 | /* force to b mode */ |
| 477 | network_type = WIRELESS_11B; |
| 478 | tx_ra_bitmap = 0xf; |
| 479 | } |
| 480 | |
| 481 | raid = networktype_to_raid23a(network_type); |
| 482 | init_rate = get_highest_rate_idx23a(tx_ra_bitmap&0x0fffffff)&0x3f; |
| 483 | |
| 484 | /* ap mode */ |
Jes Sorensen | dbe9849 | 2014-05-16 10:04:13 +0200 | [diff] [blame] | 485 | rtl8723a_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 486 | |
| 487 | { |
| 488 | u8 arg = 0; |
| 489 | |
| 490 | arg = psta->mac_id&0x1f; |
| 491 | |
| 492 | arg |= BIT(7); |
| 493 | |
| 494 | tx_ra_bitmap |= ((raid<<28)&0xf0000000); |
| 495 | |
| 496 | DBG_8723A("update_bmc_sta, mask = 0x%x, arg = 0x%x\n", tx_ra_bitmap, arg); |
| 497 | |
| 498 | /* bitmap[0:27] = tx_rate_bitmap */ |
| 499 | /* bitmap[28:31]= Rate Adaptive id */ |
| 500 | /* arg[0:4] = macid */ |
| 501 | /* arg[5] = Short GI */ |
Jes Sorensen | 1ec6934 | 2014-05-16 10:04:11 +0200 | [diff] [blame] | 502 | rtl8723a_add_rateatid(padapter, tx_ra_bitmap, arg, 0); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | /* set ra_id, init_rate */ |
| 506 | psta->raid = raid; |
| 507 | psta->init_rate = init_rate; |
| 508 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 509 | spin_lock_bh(&psta->lock); |
| 510 | psta->state = _FW_LINKED; |
| 511 | spin_unlock_bh(&psta->lock); |
| 512 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 513 | } else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 514 | DBG_8723A("add_RATid23a_bmc_sta error!\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | /* notes: */ |
| 518 | /* AID: 1~MAX for sta and 0 for bc/mc in ap/adhoc mode */ |
| 519 | /* MAC_ID = AID+1 for sta in ap/adhoc mode */ |
| 520 | /* MAC_ID = 1 for bc/mc for sta/ap/adhoc */ |
| 521 | /* MAC_ID = 0 for bssid for sta/ap/adhoc */ |
| 522 | /* CAM_ID = 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */ |
| 523 | |
| 524 | void update_sta_info23a_apmode23a(struct rtw_adapter *padapter, struct sta_info *psta) |
| 525 | { |
| 526 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 527 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
| 528 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 529 | struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; |
| 530 | struct ht_priv *phtpriv_sta = &psta->htpriv; |
| 531 | /* set intf_tag to if1 */ |
| 532 | |
| 533 | psta->mac_id = psta->aid+1; |
| 534 | DBG_8723A("%s\n", __func__); |
| 535 | |
| 536 | /* ap mode */ |
Jes Sorensen | dbe9849 | 2014-05-16 10:04:13 +0200 | [diff] [blame] | 537 | rtl8723a_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 538 | |
| 539 | if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) |
| 540 | psta->ieee8021x_blocked = true; |
| 541 | else |
| 542 | psta->ieee8021x_blocked = false; |
| 543 | |
| 544 | /* update sta's cap */ |
| 545 | |
| 546 | /* ERP */ |
| 547 | VCS_update23a(padapter, psta); |
| 548 | /* HT related cap */ |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 549 | if (phtpriv_sta->ht_option) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 550 | /* check if sta supports rx ampdu */ |
| 551 | phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable; |
| 552 | |
| 553 | /* check if sta support s Short GI */ |
| 554 | if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40)) |
| 555 | phtpriv_sta->sgi = true; |
| 556 | |
| 557 | /* bwmode */ |
| 558 | if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40)) { |
| 559 | /* phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_40; */ |
| 560 | phtpriv_sta->bwmode = pmlmeext->cur_bwmode; |
| 561 | phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; |
| 562 | |
| 563 | } |
| 564 | |
| 565 | psta->qos_option = true; |
| 566 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 567 | } else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 568 | phtpriv_sta->ampdu_enable = false; |
| 569 | |
| 570 | phtpriv_sta->sgi = false; |
| 571 | phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20; |
| 572 | phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; |
| 573 | } |
| 574 | |
| 575 | /* Rx AMPDU */ |
| 576 | send_delba23a(padapter, 0, psta->hwaddr);/* recipient */ |
| 577 | |
| 578 | /* TX AMPDU */ |
| 579 | send_delba23a(padapter, 1, psta->hwaddr);/* originator */ |
| 580 | phtpriv_sta->agg_enable_bitmap = 0x0;/* reset */ |
| 581 | phtpriv_sta->candidate_tid_bitmap = 0x0;/* reset */ |
| 582 | |
| 583 | /* todo: init other variables */ |
| 584 | |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 585 | memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 586 | |
| 587 | spin_lock_bh(&psta->lock); |
| 588 | psta->state |= _FW_LINKED; |
| 589 | spin_unlock_bh(&psta->lock); |
| 590 | } |
| 591 | |
| 592 | static void update_hw_ht_param(struct rtw_adapter *padapter) |
| 593 | { |
| 594 | unsigned char max_AMPDU_len; |
| 595 | unsigned char min_MPDU_spacing; |
| 596 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 597 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 598 | |
| 599 | DBG_8723A("%s\n", __func__); |
| 600 | |
| 601 | /* handle A-MPDU parameter field */ |
| 602 | /* |
| 603 | AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k |
| 604 | AMPDU_para [4:2]:Min MPDU Start Spacing |
| 605 | */ |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 606 | max_AMPDU_len = pmlmeinfo->ht_cap.ampdu_params_info & |
| 607 | IEEE80211_HT_AMPDU_PARM_FACTOR; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 608 | |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 609 | min_MPDU_spacing = (pmlmeinfo->ht_cap.ampdu_params_info & |
| 610 | IEEE80211_HT_AMPDU_PARM_DENSITY) >> 2; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 611 | |
Jes Sorensen | dce610a | 2014-04-09 23:20:32 +0200 | [diff] [blame] | 612 | rtl8723a_set_ampdu_min_space(padapter, min_MPDU_spacing); |
| 613 | rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 614 | |
| 615 | /* Config SM Power Save setting */ |
Jes Sorensen | 65be27d | 2014-05-31 18:05:11 +0200 | [diff] [blame] | 616 | pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->ht_cap.cap_info) & |
| 617 | IEEE80211_HT_CAP_SM_PS) >> 2; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 618 | if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) |
| 619 | DBG_8723A("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); |
| 620 | } |
| 621 | |
| 622 | static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) |
| 623 | { |
Jes Sorensen | 731f9da | 2014-04-15 19:44:02 +0200 | [diff] [blame] | 624 | const u8 *p; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 625 | u8 val8, cur_channel, cur_bwmode, cur_ch_offset; |
| 626 | u16 bcn_interval; |
| 627 | u32 acparm; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 628 | struct registry_priv *pregpriv = &padapter->registrypriv; |
| 629 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 630 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
Jes Sorensen | 5201795 | 2014-04-26 18:55:09 +0200 | [diff] [blame] | 631 | struct wlan_bssid_ex *pnetwork = &pmlmepriv->cur_network.network; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 632 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 633 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 634 | struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 635 | struct ieee80211_ht_operation *pht_info = NULL; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 636 | |
Jes Sorensen | 143ced2 | 2014-06-19 11:37:22 +0200 | [diff] [blame] | 637 | bcn_interval = (u16)pnetwork->beacon_interval; |
Jes Sorensen | 37cb982 | 2014-05-21 09:37:40 +0200 | [diff] [blame] | 638 | cur_channel = pnetwork->DSConfig; |
Roberta Dobrescu | b9b4224 | 2014-10-26 23:30:06 +0200 | [diff] [blame] | 639 | cur_bwmode = HT_CHANNEL_WIDTH_20; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 640 | cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; |
| 641 | |
| 642 | /* check if there is wps ie, */ |
| 643 | /* if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd, */ |
| 644 | /* and at first time the security ie (RSN/WPA IE) will not include in beacon. */ |
Jes Sorensen | 715a8a7 | 2014-06-09 15:15:57 +0200 | [diff] [blame] | 645 | if (NULL == cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, |
| 646 | WLAN_OUI_TYPE_MICROSOFT_WPS, |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 647 | pnetwork->IEs, |
| 648 | pnetwork->IELength)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 649 | pmlmeext->bstart_bss = true; |
| 650 | |
| 651 | /* todo: update wmm, ht cap */ |
| 652 | /* pmlmeinfo->WMM_enable; */ |
| 653 | /* pmlmeinfo->HT_enable; */ |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 654 | if (pmlmepriv->qos_option) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 655 | pmlmeinfo->WMM_enable = true; |
| 656 | if (pmlmepriv->htpriv.ht_option) { |
| 657 | pmlmeinfo->WMM_enable = true; |
| 658 | pmlmeinfo->HT_enable = true; |
| 659 | |
| 660 | update_hw_ht_param(padapter); |
| 661 | } |
| 662 | |
| 663 | if (pmlmepriv->cur_network.join_res != true) { |
| 664 | /* setting only at first time */ |
| 665 | /* WEP Key will be set before this function, do not clear CAM. */ |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 666 | if (psecuritypriv->dot11PrivacyAlgrthm != |
| 667 | WLAN_CIPHER_SUITE_WEP40 && |
| 668 | psecuritypriv->dot11PrivacyAlgrthm != |
| 669 | WLAN_CIPHER_SUITE_WEP104) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 670 | flush_all_cam_entry23a(padapter); /* clear CAM */ |
| 671 | } |
| 672 | |
| 673 | /* set MSR to AP_Mode */ |
Jes Sorensen | 6ec2627 | 2014-07-17 22:59:46 +0200 | [diff] [blame] | 674 | rtl8723a_set_media_status(padapter, MSR_AP); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 675 | |
| 676 | /* Set BSSID REG */ |
Jes Sorensen | 38dd10b | 2014-04-09 23:20:20 +0200 | [diff] [blame] | 677 | hw_var_set_bssid(padapter, pnetwork->MacAddress); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 678 | |
| 679 | /* Set EDCA param reg */ |
| 680 | acparm = 0x002F3217; /* VO */ |
Jes Sorensen | 2487205e | 2014-04-09 23:20:30 +0200 | [diff] [blame] | 681 | rtl8723a_set_ac_param_vo(padapter, acparm); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 682 | acparm = 0x005E4317; /* VI */ |
Jes Sorensen | 2487205e | 2014-04-09 23:20:30 +0200 | [diff] [blame] | 683 | rtl8723a_set_ac_param_vi(padapter, acparm); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 684 | acparm = 0x005ea42b; |
Jes Sorensen | 2487205e | 2014-04-09 23:20:30 +0200 | [diff] [blame] | 685 | rtl8723a_set_ac_param_be(padapter, acparm); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 686 | acparm = 0x0000A444; /* BK */ |
Jes Sorensen | 2487205e | 2014-04-09 23:20:30 +0200 | [diff] [blame] | 687 | rtl8723a_set_ac_param_bk(padapter, acparm); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 688 | |
| 689 | /* Set Security */ |
Jes Sorensen | b8e9916 | 2014-04-09 23:20:27 +0200 | [diff] [blame] | 690 | val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ? |
MihaelaGaman | adabff8 | 2014-09-14 12:56:43 +0300 | [diff] [blame] | 691 | 0xcc : 0xcf; |
Jes Sorensen | b8e9916 | 2014-04-09 23:20:27 +0200 | [diff] [blame] | 692 | rtl8723a_set_sec_cfg(padapter, val8); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 693 | |
| 694 | /* Beacon Control related register */ |
Jes Sorensen | 477f008 | 2014-04-09 23:20:23 +0200 | [diff] [blame] | 695 | rtl8723a_set_beacon_interval(padapter, bcn_interval); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 696 | |
| 697 | UpdateBrateTbl23a(padapter, pnetwork->SupportedRates); |
Jes Sorensen | fa2e520 | 2014-04-09 23:20:18 +0200 | [diff] [blame] | 698 | HalSetBrateCfg23a(padapter, pnetwork->SupportedRates); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 699 | |
| 700 | if (!pmlmepriv->cur_network.join_res) { |
| 701 | /* setting only at first time */ |
| 702 | |
| 703 | /* disable dynamic functions, such as high power, DIG */ |
| 704 | |
| 705 | /* turn on all dynamic functions */ |
Jes Sorensen | 585eefb | 2014-04-09 23:20:43 +0200 | [diff] [blame] | 706 | rtl8723a_odm_support_ability_set(padapter, |
| 707 | DYNAMIC_ALL_FUNC_ENABLE); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 708 | } |
| 709 | /* set channel, bwmode */ |
Jes Sorensen | c164bcf | 2014-05-21 09:37:41 +0200 | [diff] [blame] | 710 | |
Jes Sorensen | 68e6c79 | 2014-06-24 15:03:29 +0200 | [diff] [blame] | 711 | p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pnetwork->IEs, |
| 712 | pnetwork->IELength); |
Jes Sorensen | 731f9da | 2014-04-15 19:44:02 +0200 | [diff] [blame] | 713 | if (p && p[1]) { |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 714 | pht_info = (struct ieee80211_ht_operation *)(p + 2); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 715 | |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 716 | if (pregpriv->cbw40_enable && pht_info->ht_param & |
| 717 | IEEE80211_HT_PARAM_CHAN_WIDTH_ANY) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 718 | /* switch to the 40M Hz mode */ |
| 719 | cur_bwmode = HT_CHANNEL_WIDTH_40; |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 720 | switch (pht_info->ht_param & |
| 721 | IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { |
| 722 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
Jes Sorensen | 731f9da | 2014-04-15 19:44:02 +0200 | [diff] [blame] | 723 | /* pmlmeext->cur_ch_offset = |
| 724 | HAL_PRIME_CHNL_OFFSET_LOWER; */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 725 | cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; |
| 726 | break; |
Jes Sorensen | 4dc5f8b | 2014-05-31 18:05:13 +0200 | [diff] [blame] | 727 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 728 | cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; |
| 729 | break; |
| 730 | default: |
| 731 | cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; |
| 732 | break; |
| 733 | } |
| 734 | } |
| 735 | } |
| 736 | /* TODO: need to judge the phy parameters on concurrent mode for single phy */ |
| 737 | set_channel_bwmode23a(padapter, cur_channel, cur_ch_offset, cur_bwmode); |
| 738 | |
| 739 | DBG_8723A("CH =%d, BW =%d, offset =%d\n", cur_channel, cur_bwmode, |
| 740 | cur_ch_offset); |
| 741 | |
| 742 | pmlmeext->cur_channel = cur_channel; |
| 743 | pmlmeext->cur_bwmode = cur_bwmode; |
| 744 | pmlmeext->cur_ch_offset = cur_ch_offset; |
| 745 | pmlmeext->cur_wireless_mode = pmlmepriv->cur_network.network_type; |
| 746 | |
| 747 | /* update cur_wireless_mode */ |
| 748 | update_wireless_mode23a(padapter); |
| 749 | |
Masanari Iida | 96b0a5b | 2014-07-22 23:42:45 +0900 | [diff] [blame] | 750 | /* update capability after cur_wireless_mode updated */ |
Jes Sorensen | a94e12b | 2014-06-19 11:37:34 +0200 | [diff] [blame] | 751 | update_capinfo23a(padapter, pnetwork->capability); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 752 | |
| 753 | /* let pnetwork_mlmeext == pnetwork_mlme. */ |
| 754 | memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); |
| 755 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 756 | if (pmlmeext->bstart_bss) { |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 757 | update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 758 | |
| 759 | /* issue beacon frame */ |
| 760 | if (send_beacon23a(padapter) == _FAIL) |
| 761 | DBG_8723A("issue_beacon23a, fail!\n"); |
| 762 | } |
| 763 | |
| 764 | /* update bc/mc sta_info */ |
| 765 | update_bmc_sta(padapter); |
| 766 | } |
| 767 | |
Jes Sorensen | fb5fd46 | 2014-06-24 15:03:20 +0200 | [diff] [blame] | 768 | int rtw_check_beacon_data23a(struct rtw_adapter *padapter, |
| 769 | struct ieee80211_mgmt *mgmt, unsigned int len) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 770 | { |
| 771 | int ret = _SUCCESS; |
| 772 | u8 *p; |
| 773 | u8 *pHT_caps_ie = NULL; |
| 774 | u8 *pHT_info_ie = NULL; |
| 775 | struct sta_info *psta = NULL; |
Jes Sorensen | 51a26d2 | 2014-06-24 15:03:21 +0200 | [diff] [blame] | 776 | u16 ht_cap = false; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 777 | uint ie_len = 0; |
| 778 | int group_cipher, pairwise_cipher; |
| 779 | u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX]; |
| 780 | int supportRateNum = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 781 | u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; |
| 782 | struct registry_priv *pregistrypriv = &padapter->registrypriv; |
| 783 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
| 784 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 785 | struct wlan_bssid_ex *pbss_network = &pmlmepriv->cur_network.network; |
| 786 | u8 *ie = pbss_network->IEs; |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 787 | u8 *pbuf = mgmt->u.beacon.variable; |
| 788 | len -= offsetof(struct ieee80211_mgmt, u.beacon.variable); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 789 | /* SSID */ |
| 790 | /* Supported rates */ |
| 791 | /* DS Params */ |
| 792 | /* WLAN_EID_COUNTRY */ |
| 793 | /* ERP Information element */ |
| 794 | /* Extended supported rates */ |
| 795 | /* WPA/WPA2 */ |
| 796 | /* Wi-Fi Wireless Multimedia Extensions */ |
| 797 | /* ht_capab, ht_oper */ |
| 798 | /* WPS IE */ |
| 799 | |
| 800 | DBG_8723A("%s, len =%d\n", __func__, len); |
| 801 | |
| 802 | if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) |
| 803 | return _FAIL; |
| 804 | |
Jes Sorensen | 8282aeb | 2014-04-26 18:54:53 +0200 | [diff] [blame] | 805 | if (len > MAX_IE_SZ) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 806 | return _FAIL; |
| 807 | |
| 808 | pbss_network->IELength = len; |
| 809 | |
| 810 | memset(ie, 0, MAX_IE_SZ); |
| 811 | |
| 812 | memcpy(ie, pbuf, pbss_network->IELength); |
| 813 | |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 814 | if (pbss_network->ifmode != NL80211_IFTYPE_AP && |
| 815 | pbss_network->ifmode != NL80211_IFTYPE_P2P_GO) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 816 | return _FAIL; |
| 817 | |
| 818 | pbss_network->Rssi = 0; |
| 819 | |
| 820 | memcpy(pbss_network->MacAddress, myid(&padapter->eeprompriv), ETH_ALEN); |
| 821 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 822 | /* SSID */ |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 823 | p = rtw_get_ie23a(ie, WLAN_EID_SSID, &ie_len, pbss_network->IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 824 | if (p && ie_len > 0) { |
| 825 | memset(&pbss_network->Ssid, 0, sizeof(struct cfg80211_ssid)); |
| 826 | memcpy(pbss_network->Ssid.ssid, (p + 2), ie_len); |
| 827 | pbss_network->Ssid.ssid_len = ie_len; |
| 828 | } |
| 829 | |
Masanari Iida | 96b0a5b | 2014-07-22 23:42:45 +0900 | [diff] [blame] | 830 | /* channel */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 831 | channel = 0; |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 832 | p = rtw_get_ie23a(ie, WLAN_EID_DS_PARAMS, &ie_len, |
| 833 | pbss_network->IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 834 | if (p && ie_len > 0) |
| 835 | channel = *(p + 2); |
| 836 | |
Jes Sorensen | 37cb982 | 2014-05-21 09:37:40 +0200 | [diff] [blame] | 837 | pbss_network->DSConfig = channel; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 838 | |
| 839 | memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); |
| 840 | /* get supported rates */ |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 841 | p = rtw_get_ie23a(ie, WLAN_EID_SUPP_RATES, &ie_len, |
| 842 | pbss_network->IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 843 | if (p) { |
| 844 | memcpy(supportRate, p+2, ie_len); |
| 845 | supportRateNum = ie_len; |
| 846 | } |
| 847 | |
| 848 | /* get ext_supported rates */ |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 849 | p = rtw_get_ie23a(ie, WLAN_EID_EXT_SUPP_RATES, |
| 850 | &ie_len, pbss_network->IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 851 | if (p) { |
| 852 | memcpy(supportRate+supportRateNum, p+2, ie_len); |
| 853 | supportRateNum += ie_len; |
| 854 | } |
| 855 | |
| 856 | network_type = rtw_check_network_type23a(supportRate, |
| 857 | supportRateNum, channel); |
| 858 | |
| 859 | rtw_set_supported_rate23a(pbss_network->SupportedRates, network_type); |
| 860 | |
| 861 | /* parsing ERP_IE */ |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 862 | p = rtw_get_ie23a(ie, WLAN_EID_ERP_INFO, &ie_len, |
| 863 | pbss_network->IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 864 | if (p && ie_len > 0) |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 865 | ERP_IE_handler23a(padapter, p); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 866 | |
| 867 | /* update privacy/security */ |
Jes Sorensen | 51a26d2 | 2014-06-24 15:03:21 +0200 | [diff] [blame] | 868 | if (pbss_network->capability & BIT(4)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 869 | pbss_network->Privacy = 1; |
| 870 | else |
| 871 | pbss_network->Privacy = 0; |
| 872 | |
| 873 | psecuritypriv->wpa_psk = 0; |
| 874 | |
| 875 | /* wpa2 */ |
| 876 | group_cipher = 0; pairwise_cipher = 0; |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 877 | psecuritypriv->wpa2_group_cipher = 0; |
| 878 | psecuritypriv->wpa2_pairwise_cipher = 0; |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 879 | p = rtw_get_ie23a(ie, WLAN_EID_RSN, &ie_len, |
| 880 | pbss_network->IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 881 | if (p && ie_len > 0) { |
| 882 | if (rtw_parse_wpa2_ie23a(p, ie_len+2, &group_cipher, |
| 883 | &pairwise_cipher, NULL) == _SUCCESS) { |
| 884 | psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; |
| 885 | |
| 886 | psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ |
| 887 | psecuritypriv->wpa_psk |= BIT(1); |
| 888 | |
| 889 | psecuritypriv->wpa2_group_cipher = group_cipher; |
| 890 | psecuritypriv->wpa2_pairwise_cipher = pairwise_cipher; |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | /* wpa */ |
| 895 | ie_len = 0; |
| 896 | group_cipher = 0; |
| 897 | pairwise_cipher = 0; |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 898 | psecuritypriv->wpa_group_cipher = 0; |
| 899 | psecuritypriv->wpa_pairwise_cipher = 0; |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 900 | for (p = ie; ;p += (ie_len + 2)) { |
Jes Sorensen | 9300c94 | 2014-04-15 19:43:21 +0200 | [diff] [blame] | 901 | p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 902 | pbss_network->IELength - (ie_len + 2)); |
Jes Sorensen | 819d181 | 2014-04-26 18:55:44 +0200 | [diff] [blame] | 903 | if ((p) && (!memcmp(p+2, RTW_WPA_OUI23A_TYPE, 4))) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 904 | if (rtw_parse_wpa_ie23a(p, ie_len+2, &group_cipher, |
| 905 | &pairwise_cipher, NULL) == _SUCCESS) { |
| 906 | psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; |
| 907 | |
| 908 | /* psk, todo:802.1x */ |
| 909 | psecuritypriv->dot8021xalg = 1; |
| 910 | |
| 911 | psecuritypriv->wpa_psk |= BIT(0); |
| 912 | |
| 913 | psecuritypriv->wpa_group_cipher = group_cipher; |
| 914 | psecuritypriv->wpa_pairwise_cipher = pairwise_cipher; |
| 915 | } |
| 916 | break; |
| 917 | } |
| 918 | |
| 919 | if ((p == NULL) || (ie_len == 0)) |
| 920 | break; |
| 921 | } |
| 922 | |
| 923 | /* wmm */ |
| 924 | ie_len = 0; |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 925 | pmlmepriv->qos_option = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 926 | if (pregistrypriv->wmm_enable) { |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 927 | for (p = ie; ;p += (ie_len + 2)) { |
Jes Sorensen | 9300c94 | 2014-04-15 19:43:21 +0200 | [diff] [blame] | 928 | p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 929 | (pbss_network->IELength - |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 930 | (ie_len + 2))); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 931 | if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) { |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 932 | pmlmepriv->qos_option = 1; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 933 | |
| 934 | *(p+8) |= BIT(7);/* QoS Info, support U-APSD */ |
| 935 | |
| 936 | /* disable all ACM bits since the WMM admission |
| 937 | * control is not supported |
| 938 | */ |
| 939 | *(p + 10) &= ~BIT(4); /* BE */ |
| 940 | *(p + 14) &= ~BIT(4); /* BK */ |
| 941 | *(p + 18) &= ~BIT(4); /* VI */ |
| 942 | *(p + 22) &= ~BIT(4); /* VO */ |
| 943 | break; |
| 944 | } |
| 945 | if ((p == NULL) || (ie_len == 0)) |
| 946 | break; |
| 947 | } |
| 948 | } |
| 949 | /* parsing HT_CAP_IE */ |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 950 | p = rtw_get_ie23a(ie, WLAN_EID_HT_CAPABILITY, &ie_len, |
| 951 | pbss_network->IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 952 | if (p && ie_len > 0) { |
| 953 | u8 rf_type; |
| 954 | |
| 955 | struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap *)(p+2); |
| 956 | |
| 957 | pHT_caps_ie = p; |
| 958 | |
| 959 | ht_cap = true; |
| 960 | network_type |= WIRELESS_11_24N; |
| 961 | |
Jes Sorensen | c2370e8 | 2014-04-09 23:20:53 +0200 | [diff] [blame] | 962 | rf_type = rtl8723a_get_rf_type(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 963 | |
| 964 | if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || |
| 965 | (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) |
| 966 | pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07<<2)); |
| 967 | else |
| 968 | pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY&0x00); |
| 969 | |
| 970 | /* set Max Rx AMPDU size to 64K */ |
| 971 | pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_FACTOR & 0x03); |
| 972 | |
| 973 | if (rf_type == RF_1T1R) { |
| 974 | pht_cap->mcs.rx_mask[0] = 0xff; |
| 975 | pht_cap->mcs.rx_mask[1] = 0x0; |
| 976 | } |
| 977 | |
| 978 | memcpy(&pmlmepriv->htpriv.ht_cap, p+2, ie_len); |
| 979 | } |
| 980 | |
| 981 | /* parsing HT_INFO_IE */ |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 982 | p = rtw_get_ie23a(ie, WLAN_EID_HT_OPERATION, &ie_len, |
| 983 | pbss_network->IELength); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 984 | if (p && ie_len > 0) |
| 985 | pHT_info_ie = p; |
| 986 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 987 | pmlmepriv->cur_network.network_type = network_type; |
| 988 | |
| 989 | pmlmepriv->htpriv.ht_option = false; |
| 990 | |
| 991 | /* ht_cap */ |
| 992 | if (pregistrypriv->ht_enable && ht_cap) { |
| 993 | pmlmepriv->htpriv.ht_option = true; |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 994 | pmlmepriv->qos_option = 1; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 995 | |
| 996 | if (pregistrypriv->ampdu_enable == 1) |
| 997 | pmlmepriv->htpriv.ampdu_enable = true; |
| 998 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 999 | HT_caps_handler23a(padapter, pHT_caps_ie); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1000 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1001 | HT_info_handler23a(padapter, pHT_info_ie); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1002 | } |
| 1003 | |
Jes Sorensen | 5201795 | 2014-04-26 18:55:09 +0200 | [diff] [blame] | 1004 | pbss_network->Length = get_wlan_bssid_ex_sz(pbss_network); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1005 | |
| 1006 | /* issue beacon to start bss network */ |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 1007 | start_bss_network(padapter, (u8 *)pbss_network); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1008 | |
| 1009 | /* alloc sta_info for ap itself */ |
| 1010 | psta = rtw_get_stainfo23a(&padapter->stapriv, pbss_network->MacAddress); |
| 1011 | if (!psta) { |
Jes Sorensen | 6e8bc71 | 2014-05-09 15:03:49 +0200 | [diff] [blame] | 1012 | psta = rtw_alloc_stainfo23a(&padapter->stapriv, |
| 1013 | pbss_network->MacAddress, |
| 1014 | GFP_KERNEL); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1015 | if (!psta) |
| 1016 | return _FAIL; |
| 1017 | } |
| 1018 | /* fix bug of flush_cam_entry at STOP AP mode */ |
| 1019 | psta->state |= WIFI_AP_STATE; |
| 1020 | rtw_indicate_connect23a(padapter); |
| 1021 | |
| 1022 | /* for check if already set beacon */ |
| 1023 | pmlmepriv->cur_network.join_res = true; |
| 1024 | |
| 1025 | return ret; |
| 1026 | } |
| 1027 | |
| 1028 | void rtw_set_macaddr_acl23a(struct rtw_adapter *padapter, int mode) |
| 1029 | { |
| 1030 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1031 | struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; |
| 1032 | |
| 1033 | DBG_8723A("%s, mode =%d\n", __func__, mode); |
| 1034 | |
| 1035 | pacl_list->mode = mode; |
| 1036 | } |
| 1037 | |
| 1038 | int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr) |
| 1039 | { |
| 1040 | struct list_head *plist, *phead; |
| 1041 | u8 added = false; |
| 1042 | int i, ret = 0; |
| 1043 | struct rtw_wlan_acl_node *paclnode; |
| 1044 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1045 | struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; |
| 1046 | struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q; |
| 1047 | |
| 1048 | DBG_8723A("%s(acl_num =%d) =" MAC_FMT "\n", __func__, pacl_list->num, MAC_ARG(addr)); |
| 1049 | |
| 1050 | if ((NUM_ACL-1) < pacl_list->num) |
| 1051 | return -1; |
| 1052 | |
| 1053 | spin_lock_bh(&pacl_node_q->lock); |
| 1054 | |
| 1055 | phead = get_list_head(pacl_node_q); |
| 1056 | |
| 1057 | list_for_each(plist, phead) { |
| 1058 | paclnode = container_of(plist, struct rtw_wlan_acl_node, list); |
| 1059 | |
| 1060 | if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { |
| 1061 | if (paclnode->valid == true) { |
| 1062 | added = true; |
| 1063 | DBG_8723A("%s, sta has been added\n", __func__); |
| 1064 | break; |
| 1065 | } |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | spin_unlock_bh(&pacl_node_q->lock); |
| 1070 | |
| 1071 | if (added) |
| 1072 | return ret; |
| 1073 | |
| 1074 | spin_lock_bh(&pacl_node_q->lock); |
| 1075 | |
| 1076 | for (i = 0; i < NUM_ACL; i++) { |
| 1077 | paclnode = &pacl_list->aclnode[i]; |
| 1078 | |
| 1079 | if (!paclnode->valid) { |
| 1080 | INIT_LIST_HEAD(&paclnode->list); |
| 1081 | |
| 1082 | memcpy(paclnode->addr, addr, ETH_ALEN); |
| 1083 | |
| 1084 | paclnode->valid = true; |
| 1085 | |
| 1086 | list_add_tail(&paclnode->list, get_list_head(pacl_node_q)); |
| 1087 | |
| 1088 | pacl_list->num++; |
| 1089 | |
| 1090 | break; |
| 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | DBG_8723A("%s, acl_num =%d\n", __func__, pacl_list->num); |
| 1095 | |
| 1096 | spin_unlock_bh(&pacl_node_q->lock); |
| 1097 | return ret; |
| 1098 | } |
| 1099 | |
| 1100 | int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr) |
| 1101 | { |
| 1102 | struct list_head *plist, *phead, *ptmp; |
| 1103 | struct rtw_wlan_acl_node *paclnode; |
| 1104 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1105 | struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; |
| 1106 | struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1107 | |
| 1108 | DBG_8723A("%s(acl_num =%d) = %pM\n", __func__, pacl_list->num, addr); |
| 1109 | |
| 1110 | spin_lock_bh(&pacl_node_q->lock); |
| 1111 | |
| 1112 | phead = get_list_head(pacl_node_q); |
| 1113 | |
| 1114 | list_for_each_safe(plist, ptmp, phead) { |
| 1115 | paclnode = container_of(plist, struct rtw_wlan_acl_node, list); |
| 1116 | |
| 1117 | if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { |
| 1118 | if (paclnode->valid) { |
| 1119 | paclnode->valid = false; |
| 1120 | |
| 1121 | list_del_init(&paclnode->list); |
| 1122 | |
| 1123 | pacl_list->num--; |
| 1124 | } |
| 1125 | } |
| 1126 | } |
| 1127 | |
| 1128 | spin_unlock_bh(&pacl_node_q->lock); |
| 1129 | |
| 1130 | DBG_8723A("%s, acl_num =%d\n", __func__, pacl_list->num); |
| 1131 | |
Heena Sirwani | f9800f8 | 2014-10-07 14:46:30 +0530 | [diff] [blame] | 1132 | return 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1133 | } |
| 1134 | |
| 1135 | static void update_bcn_fixed_ie(struct rtw_adapter *padapter) |
| 1136 | { |
| 1137 | DBG_8723A("%s\n", __func__); |
| 1138 | } |
| 1139 | |
| 1140 | static void update_bcn_erpinfo_ie(struct rtw_adapter *padapter) |
| 1141 | { |
| 1142 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1143 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1144 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 1145 | struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; |
| 1146 | unsigned char *p, *ie = pnetwork->IEs; |
| 1147 | u32 len = 0; |
| 1148 | |
| 1149 | DBG_8723A("%s, ERP_enable =%d\n", __func__, pmlmeinfo->ERP_enable); |
| 1150 | |
| 1151 | if (!pmlmeinfo->ERP_enable) |
| 1152 | return; |
| 1153 | |
| 1154 | /* parsing ERP_IE */ |
Jes Sorensen | 1de65cc | 2014-06-24 15:03:30 +0200 | [diff] [blame] | 1155 | p = rtw_get_ie23a(ie, WLAN_EID_ERP_INFO, &len, pnetwork->IELength); |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1156 | if (p && len > 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1157 | if (pmlmepriv->num_sta_non_erp == 1) |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1158 | p[2] |= WLAN_ERP_NON_ERP_PRESENT | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1159 | WLAN_ERP_USE_PROTECTION; |
| 1160 | else |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1161 | p[2] &= ~(WLAN_ERP_NON_ERP_PRESENT | |
| 1162 | WLAN_ERP_USE_PROTECTION); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1163 | |
| 1164 | if (pmlmepriv->num_sta_no_short_preamble > 0) |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1165 | p[2] |= WLAN_ERP_BARKER_PREAMBLE; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1166 | else |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1167 | p[2] &= ~(WLAN_ERP_BARKER_PREAMBLE); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1168 | |
Jes Sorensen | b171da3 | 2014-05-21 09:37:42 +0200 | [diff] [blame] | 1169 | ERP_IE_handler23a(padapter, p); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1170 | } |
| 1171 | } |
| 1172 | |
| 1173 | static void update_bcn_htcap_ie(struct rtw_adapter *padapter) |
| 1174 | { |
| 1175 | DBG_8723A("%s\n", __func__); |
| 1176 | } |
| 1177 | |
| 1178 | static void update_bcn_htinfo_ie(struct rtw_adapter *padapter) |
| 1179 | { |
| 1180 | DBG_8723A("%s\n", __func__); |
| 1181 | } |
| 1182 | |
| 1183 | static void update_bcn_rsn_ie(struct rtw_adapter *padapter) |
| 1184 | { |
| 1185 | DBG_8723A("%s\n", __func__); |
| 1186 | } |
| 1187 | |
| 1188 | static void update_bcn_wpa_ie(struct rtw_adapter *padapter) |
| 1189 | { |
| 1190 | DBG_8723A("%s\n", __func__); |
| 1191 | } |
| 1192 | |
| 1193 | static void update_bcn_wmm_ie(struct rtw_adapter *padapter) |
| 1194 | { |
| 1195 | DBG_8723A("%s\n", __func__); |
| 1196 | } |
| 1197 | |
| 1198 | static void update_bcn_wps_ie(struct rtw_adapter *padapter) |
| 1199 | { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1200 | DBG_8723A("%s\n", __func__); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1201 | } |
| 1202 | |
| 1203 | static void update_bcn_p2p_ie(struct rtw_adapter *padapter) |
| 1204 | { |
| 1205 | } |
| 1206 | |
| 1207 | static void update_bcn_vendor_spec_ie(struct rtw_adapter *padapter, u8*oui) |
| 1208 | { |
| 1209 | DBG_8723A("%s\n", __func__); |
| 1210 | |
Jes Sorensen | 7964eba0 | 2014-04-15 19:44:11 +0200 | [diff] [blame] | 1211 | if (!memcmp(RTW_WPA_OUI23A_TYPE, oui, 4)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1212 | update_bcn_wpa_ie(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1213 | else if (!memcmp(WMM_OUI23A, oui, 4)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1214 | update_bcn_wmm_ie(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1215 | else if (!memcmp(WPS_OUI23A, oui, 4)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1216 | update_bcn_wps_ie(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1217 | else if (!memcmp(P2P_OUI23A, oui, 4)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1218 | update_bcn_p2p_ie(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1219 | else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1220 | DBG_8723A("unknown OUI type!\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1221 | } |
| 1222 | |
| 1223 | void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) |
| 1224 | { |
| 1225 | struct mlme_priv *pmlmepriv; |
| 1226 | struct mlme_ext_priv *pmlmeext; |
| 1227 | /* struct mlme_ext_info *pmlmeinfo; */ |
| 1228 | |
| 1229 | /* DBG_8723A("%s\n", __func__); */ |
| 1230 | |
| 1231 | if (!padapter) |
| 1232 | return; |
| 1233 | |
| 1234 | pmlmepriv = &padapter->mlmepriv; |
| 1235 | pmlmeext = &padapter->mlmeextpriv; |
| 1236 | /* pmlmeinfo = &pmlmeext->mlmext_info; */ |
| 1237 | |
| 1238 | if (false == pmlmeext->bstart_bss) |
| 1239 | return; |
| 1240 | |
| 1241 | spin_lock_bh(&pmlmepriv->bcn_update_lock); |
| 1242 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1243 | switch (ie_id) { |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 1244 | case 0xFF: |
| 1245 | /* 8: TimeStamp, 2: Beacon Interval 2:Capability */ |
| 1246 | update_bcn_fixed_ie(padapter); |
| 1247 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1248 | |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 1249 | case WLAN_EID_TIM: |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 1250 | update_BCNTIM(padapter); |
| 1251 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1252 | |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 1253 | case WLAN_EID_ERP_INFO: |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 1254 | update_bcn_erpinfo_ie(padapter); |
| 1255 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1256 | |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 1257 | case WLAN_EID_HT_CAPABILITY: |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 1258 | update_bcn_htcap_ie(padapter); |
| 1259 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1260 | |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 1261 | case WLAN_EID_RSN: |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 1262 | update_bcn_rsn_ie(padapter); |
| 1263 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1264 | |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 1265 | case WLAN_EID_HT_OPERATION: |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 1266 | update_bcn_htinfo_ie(padapter); |
| 1267 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1268 | |
Jes Sorensen | 9300c94 | 2014-04-15 19:43:21 +0200 | [diff] [blame] | 1269 | case WLAN_EID_VENDOR_SPECIFIC: |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 1270 | update_bcn_vendor_spec_ie(padapter, oui); |
| 1271 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1272 | |
Jes Sorensen | b54e880 | 2014-04-09 23:20:52 +0200 | [diff] [blame] | 1273 | default: |
| 1274 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | pmlmepriv->update_bcn = true; |
| 1278 | |
| 1279 | spin_unlock_bh(&pmlmepriv->bcn_update_lock); |
| 1280 | |
| 1281 | if (tx) |
| 1282 | set_tx_beacon_cmd23a(padapter); |
| 1283 | } |
| 1284 | |
| 1285 | /* |
| 1286 | op_mode |
Masanari Iida | 96b0a5b | 2014-07-22 23:42:45 +0900 | [diff] [blame] | 1287 | Set to 0 (HT pure) under the following conditions |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1288 | - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or |
| 1289 | - all STAs in the BSS are 20 MHz HT in 20 MHz BSS |
| 1290 | Set to 1 (HT non-member protection) if there may be non-HT STAs |
| 1291 | in both the primary and the secondary channel |
| 1292 | Set to 2 if only HT STAs are associated in BSS, |
| 1293 | however and at least one 20 MHz HT STA is associated |
| 1294 | Set to 3 (HT mixed mode) when one or more non-HT STAs are associated |
| 1295 | (currently non-GF HT station is considered as non-HT STA also) |
| 1296 | */ |
| 1297 | static int rtw_ht_operation_update(struct rtw_adapter *padapter) |
| 1298 | { |
| 1299 | u16 cur_op_mode, new_op_mode; |
| 1300 | int op_mode_changes = 0; |
| 1301 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1302 | struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; |
| 1303 | |
Jes Sorensen | 6a5f657 | 2014-06-09 15:16:07 +0200 | [diff] [blame] | 1304 | if (pmlmepriv->htpriv.ht_option) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1305 | return 0; |
| 1306 | |
| 1307 | /* if (!iface->conf->ieee80211n || iface->conf->ht_op_mode_fixed) */ |
| 1308 | /* return 0; */ |
| 1309 | |
| 1310 | DBG_8723A("%s current operation mode = 0x%X\n", |
| 1311 | __func__, pmlmepriv->ht_op_mode); |
| 1312 | |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1313 | if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1314 | && pmlmepriv->num_sta_ht_no_gf) { |
| 1315 | pmlmepriv->ht_op_mode |= |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1316 | IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1317 | op_mode_changes++; |
| 1318 | } else if ((pmlmepriv->ht_op_mode & |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1319 | IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) && |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1320 | pmlmepriv->num_sta_ht_no_gf == 0) { |
| 1321 | pmlmepriv->ht_op_mode &= |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1322 | ~IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1323 | op_mode_changes++; |
| 1324 | } |
| 1325 | |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1326 | if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) && |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1327 | (pmlmepriv->num_sta_no_ht || pmlmepriv->olbc_ht)) { |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1328 | pmlmepriv->ht_op_mode |= IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1329 | op_mode_changes++; |
| 1330 | } else if ((pmlmepriv->ht_op_mode & |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1331 | IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) && |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1332 | (pmlmepriv->num_sta_no_ht == 0 && !pmlmepriv->olbc_ht)) { |
| 1333 | pmlmepriv->ht_op_mode &= |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1334 | ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1335 | op_mode_changes++; |
| 1336 | } |
| 1337 | |
| 1338 | /* Note: currently we switch to the MIXED op mode if HT non-greenfield |
| 1339 | * station is associated. Probably it's a theoretical case, since |
| 1340 | * it looks like all known HT STAs support greenfield. |
| 1341 | */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1342 | if (pmlmepriv->num_sta_no_ht || |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1343 | (pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)) |
Jes Sorensen | c389928 | 2014-05-21 09:37:51 +0200 | [diff] [blame] | 1344 | new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED; |
Larry Finger | a96ae6f | 2014-04-26 18:55:18 +0200 | [diff] [blame] | 1345 | else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & |
| 1346 | IEEE80211_HT_CAP_SUP_WIDTH_20_40) && |
| 1347 | pmlmepriv->num_sta_ht_20mhz) |
Jes Sorensen | c389928 | 2014-05-21 09:37:51 +0200 | [diff] [blame] | 1348 | new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1349 | else if (pmlmepriv->olbc_ht) |
Jes Sorensen | c389928 | 2014-05-21 09:37:51 +0200 | [diff] [blame] | 1350 | new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1351 | else |
Jes Sorensen | c389928 | 2014-05-21 09:37:51 +0200 | [diff] [blame] | 1352 | new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONE; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1353 | |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1354 | cur_op_mode = pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_PROTECTION; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1355 | if (cur_op_mode != new_op_mode) { |
Jes Sorensen | 2c50c7c | 2014-05-21 09:37:47 +0200 | [diff] [blame] | 1356 | pmlmepriv->ht_op_mode &= ~IEEE80211_HT_OP_MODE_PROTECTION; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1357 | pmlmepriv->ht_op_mode |= new_op_mode; |
| 1358 | op_mode_changes++; |
| 1359 | } |
| 1360 | |
| 1361 | DBG_8723A("%s new operation mode = 0x%X changes =%d\n", |
| 1362 | __func__, pmlmepriv->ht_op_mode, op_mode_changes); |
| 1363 | |
| 1364 | return op_mode_changes; |
| 1365 | } |
| 1366 | |
| 1367 | void associated_clients_update23a(struct rtw_adapter *padapter, u8 updated) |
| 1368 | { |
Masanari Iida | 96b0a5b | 2014-07-22 23:42:45 +0900 | [diff] [blame] | 1369 | /* update associated stations cap. */ |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1370 | if (updated == true) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1371 | struct list_head *phead, *plist, *ptmp; |
| 1372 | struct sta_info *psta; |
| 1373 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1374 | |
| 1375 | spin_lock_bh(&pstapriv->asoc_list_lock); |
| 1376 | |
| 1377 | phead = &pstapriv->asoc_list; |
| 1378 | |
| 1379 | list_for_each_safe(plist, ptmp, phead) { |
| 1380 | psta = container_of(plist, struct sta_info, asoc_list); |
| 1381 | |
| 1382 | VCS_update23a(padapter, psta); |
| 1383 | } |
| 1384 | |
| 1385 | spin_unlock_bh(&pstapriv->asoc_list_lock); |
| 1386 | } |
| 1387 | } |
| 1388 | |
| 1389 | /* called > TSR LEVEL for USB or SDIO Interface*/ |
| 1390 | void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info *psta) |
| 1391 | { |
| 1392 | u8 beacon_updated = false; |
| 1393 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1394 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1395 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1396 | if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) { |
| 1397 | if (!psta->no_short_preamble_set) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1398 | psta->no_short_preamble_set = 1; |
| 1399 | |
| 1400 | pmlmepriv->num_sta_no_short_preamble++; |
| 1401 | |
| 1402 | if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1403 | (pmlmepriv->num_sta_no_short_preamble == 1)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1404 | beacon_updated = true; |
| 1405 | update_beacon23a(padapter, 0xFF, NULL, true); |
| 1406 | } |
| 1407 | |
| 1408 | } |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1409 | } else { |
| 1410 | if (psta->no_short_preamble_set) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1411 | psta->no_short_preamble_set = 0; |
| 1412 | |
| 1413 | pmlmepriv->num_sta_no_short_preamble--; |
| 1414 | |
| 1415 | if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1416 | (pmlmepriv->num_sta_no_short_preamble == 0)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1417 | beacon_updated = true; |
| 1418 | update_beacon23a(padapter, 0xFF, NULL, true); |
| 1419 | } |
| 1420 | |
| 1421 | } |
| 1422 | } |
| 1423 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1424 | if (psta->flags & WLAN_STA_NONERP) { |
| 1425 | if (!psta->nonerp_set) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1426 | psta->nonerp_set = 1; |
| 1427 | |
| 1428 | pmlmepriv->num_sta_non_erp++; |
| 1429 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1430 | if (pmlmepriv->num_sta_non_erp == 1) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1431 | beacon_updated = true; |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 1432 | update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1433 | } |
| 1434 | } |
| 1435 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1436 | } else { |
| 1437 | if (psta->nonerp_set) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1438 | psta->nonerp_set = 0; |
| 1439 | |
| 1440 | pmlmepriv->num_sta_non_erp--; |
| 1441 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1442 | if (pmlmepriv->num_sta_non_erp == 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1443 | beacon_updated = true; |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 1444 | update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1445 | } |
| 1446 | } |
| 1447 | |
| 1448 | } |
| 1449 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1450 | if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) { |
| 1451 | if (!psta->no_short_slot_time_set) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1452 | psta->no_short_slot_time_set = 1; |
| 1453 | |
| 1454 | pmlmepriv->num_sta_no_short_slot_time++; |
| 1455 | |
| 1456 | if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1457 | (pmlmepriv->num_sta_no_short_slot_time == 1)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1458 | beacon_updated = true; |
| 1459 | update_beacon23a(padapter, 0xFF, NULL, true); |
| 1460 | } |
| 1461 | |
| 1462 | } |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1463 | } else { |
| 1464 | if (psta->no_short_slot_time_set) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1465 | psta->no_short_slot_time_set = 0; |
| 1466 | |
| 1467 | pmlmepriv->num_sta_no_short_slot_time--; |
| 1468 | |
| 1469 | if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1470 | (pmlmepriv->num_sta_no_short_slot_time == 0)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1471 | beacon_updated = true; |
| 1472 | update_beacon23a(padapter, 0xFF, NULL, true); |
| 1473 | } |
| 1474 | } |
| 1475 | } |
| 1476 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1477 | if (psta->flags & WLAN_STA_HT) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1478 | u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info); |
| 1479 | |
| 1480 | DBG_8723A("HT: STA " MAC_FMT " HT Capabilities " |
| 1481 | "Info: 0x%04x\n", MAC_ARG(psta->hwaddr), ht_capab); |
| 1482 | |
| 1483 | if (psta->no_ht_set) { |
| 1484 | psta->no_ht_set = 0; |
| 1485 | pmlmepriv->num_sta_no_ht--; |
| 1486 | } |
| 1487 | |
| 1488 | if ((ht_capab & IEEE80211_HT_CAP_GRN_FLD) == 0) { |
| 1489 | if (!psta->no_ht_gf_set) { |
| 1490 | psta->no_ht_gf_set = 1; |
| 1491 | pmlmepriv->num_sta_ht_no_gf++; |
| 1492 | } |
| 1493 | DBG_8723A("%s STA " MAC_FMT " - no " |
| 1494 | "greenfield, num of non-gf stations %d\n", |
| 1495 | __func__, MAC_ARG(psta->hwaddr), |
| 1496 | pmlmepriv->num_sta_ht_no_gf); |
| 1497 | } |
| 1498 | |
| 1499 | if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH_20_40) == 0) { |
| 1500 | if (!psta->ht_20mhz_set) { |
| 1501 | psta->ht_20mhz_set = 1; |
| 1502 | pmlmepriv->num_sta_ht_20mhz++; |
| 1503 | } |
| 1504 | DBG_8723A("%s STA " MAC_FMT " - 20 MHz HT, " |
| 1505 | "num of 20MHz HT STAs %d\n", |
| 1506 | __func__, MAC_ARG(psta->hwaddr), |
| 1507 | pmlmepriv->num_sta_ht_20mhz); |
| 1508 | } |
| 1509 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1510 | } else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1511 | if (!psta->no_ht_set) { |
| 1512 | psta->no_ht_set = 1; |
| 1513 | pmlmepriv->num_sta_no_ht++; |
| 1514 | } |
Jes Sorensen | 6a5f657 | 2014-06-09 15:16:07 +0200 | [diff] [blame] | 1515 | if (pmlmepriv->htpriv.ht_option) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1516 | DBG_8723A("%s STA " MAC_FMT |
| 1517 | " - no HT, num of non-HT stations %d\n", |
| 1518 | __func__, MAC_ARG(psta->hwaddr), |
| 1519 | pmlmepriv->num_sta_no_ht); |
| 1520 | } |
| 1521 | } |
| 1522 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1523 | if (rtw_ht_operation_update(padapter) > 0) { |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 1524 | update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); |
| 1525 | update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1526 | } |
| 1527 | |
Masanari Iida | 96b0a5b | 2014-07-22 23:42:45 +0900 | [diff] [blame] | 1528 | /* update associated stations cap. */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1529 | associated_clients_update23a(padapter, beacon_updated); |
| 1530 | |
| 1531 | DBG_8723A("%s, updated =%d\n", __func__, beacon_updated); |
| 1532 | } |
| 1533 | |
| 1534 | u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info *psta) |
| 1535 | { |
| 1536 | u8 beacon_updated = false; |
| 1537 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1538 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1539 | |
| 1540 | if (!psta) |
| 1541 | return beacon_updated; |
| 1542 | |
| 1543 | if (psta->no_short_preamble_set) { |
| 1544 | psta->no_short_preamble_set = 0; |
| 1545 | pmlmepriv->num_sta_no_short_preamble--; |
| 1546 | if (pmlmeext->cur_wireless_mode > WIRELESS_11B |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1547 | && pmlmepriv->num_sta_no_short_preamble == 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1548 | beacon_updated = true; |
| 1549 | update_beacon23a(padapter, 0xFF, NULL, true); |
| 1550 | } |
| 1551 | } |
| 1552 | |
| 1553 | if (psta->nonerp_set) { |
| 1554 | psta->nonerp_set = 0; |
| 1555 | pmlmepriv->num_sta_non_erp--; |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1556 | if (pmlmepriv->num_sta_non_erp == 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1557 | beacon_updated = true; |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 1558 | update_beacon23a(padapter, WLAN_EID_ERP_INFO, |
| 1559 | NULL, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1560 | } |
| 1561 | } |
| 1562 | |
| 1563 | if (psta->no_short_slot_time_set) { |
| 1564 | psta->no_short_slot_time_set = 0; |
| 1565 | pmlmepriv->num_sta_no_short_slot_time--; |
| 1566 | if (pmlmeext->cur_wireless_mode > WIRELESS_11B |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1567 | && pmlmepriv->num_sta_no_short_slot_time == 0) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1568 | beacon_updated = true; |
| 1569 | update_beacon23a(padapter, 0xFF, NULL, true); |
| 1570 | } |
| 1571 | } |
| 1572 | |
| 1573 | if (psta->no_ht_gf_set) { |
| 1574 | psta->no_ht_gf_set = 0; |
| 1575 | pmlmepriv->num_sta_ht_no_gf--; |
| 1576 | } |
| 1577 | |
| 1578 | if (psta->no_ht_set) { |
| 1579 | psta->no_ht_set = 0; |
| 1580 | pmlmepriv->num_sta_no_ht--; |
| 1581 | } |
| 1582 | |
| 1583 | if (psta->ht_20mhz_set) { |
| 1584 | psta->ht_20mhz_set = 0; |
| 1585 | pmlmepriv->num_sta_ht_20mhz--; |
| 1586 | } |
| 1587 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1588 | if (rtw_ht_operation_update(padapter) > 0) { |
Jes Sorensen | af2cb2c | 2014-04-15 19:43:26 +0200 | [diff] [blame] | 1589 | update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); |
| 1590 | update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1591 | } |
| 1592 | |
Masanari Iida | 96b0a5b | 2014-07-22 23:42:45 +0900 | [diff] [blame] | 1593 | /* update associated stations cap. */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1594 | |
| 1595 | DBG_8723A("%s, updated =%d\n", __func__, beacon_updated); |
| 1596 | |
| 1597 | return beacon_updated; |
| 1598 | } |
| 1599 | |
| 1600 | u8 ap_free_sta23a(struct rtw_adapter *padapter, struct sta_info *psta, bool active, u16 reason) |
| 1601 | { |
| 1602 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1603 | u8 beacon_updated = false; |
| 1604 | |
| 1605 | if (!psta) |
| 1606 | return beacon_updated; |
| 1607 | |
Roberta Dobrescu | 08551cb | 2014-10-26 23:30:05 +0200 | [diff] [blame] | 1608 | if (active) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1609 | /* tear down Rx AMPDU */ |
| 1610 | send_delba23a(padapter, 0, psta->hwaddr);/* recipient */ |
| 1611 | |
| 1612 | /* tear down TX AMPDU */ |
| 1613 | send_delba23a(padapter, 1, psta->hwaddr);/* originator */ |
| 1614 | |
| 1615 | issue_deauth23a(padapter, psta->hwaddr, reason); |
| 1616 | } |
| 1617 | |
| 1618 | psta->htpriv.agg_enable_bitmap = 0x0;/* reset */ |
| 1619 | psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */ |
| 1620 | |
| 1621 | /* report_del_sta_event23a(padapter, psta->hwaddr, reason); */ |
| 1622 | |
| 1623 | /* clear cam entry / key */ |
| 1624 | /* clear_cam_entry23a(padapter, (psta->mac_id + 3)); */ |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 1625 | rtw_clearstakey_cmd23a(padapter, (u8 *)psta, (u8)(psta->mac_id + 3), |
| 1626 | true); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1627 | |
| 1628 | spin_lock_bh(&psta->lock); |
| 1629 | psta->state &= ~_FW_LINKED; |
| 1630 | spin_unlock_bh(&psta->lock); |
| 1631 | |
| 1632 | rtw_cfg80211_indicate_sta_disassoc(padapter, psta->hwaddr, reason); |
| 1633 | |
| 1634 | report_del_sta_event23a(padapter, psta->hwaddr, reason); |
| 1635 | |
| 1636 | beacon_updated = bss_cap_update_on_sta_leave23a(padapter, psta); |
| 1637 | |
| 1638 | spin_lock_bh(&pstapriv->sta_hash_lock); |
| 1639 | rtw_free_stainfo23a(padapter, psta); |
| 1640 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 1641 | |
| 1642 | return beacon_updated; |
| 1643 | } |
| 1644 | |
| 1645 | int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_offset) |
| 1646 | { |
| 1647 | struct list_head *phead, *plist; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1648 | struct sta_info *psta = NULL; |
| 1649 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1650 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1651 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 1652 | u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1653 | |
Jes Sorensen | 6ec2627 | 2014-07-17 22:59:46 +0200 | [diff] [blame] | 1654 | if ((pmlmeinfo->state&0x03) != MSR_AP) |
Heena Sirwani | f9800f8 | 2014-10-07 14:46:30 +0530 | [diff] [blame] | 1655 | return 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1656 | |
Jes Sorensen | a790d58 | 2014-05-09 15:04:04 +0200 | [diff] [blame] | 1657 | DBG_8723A("%s(%s): with ch:%u, offset:%u\n", __func__, |
| 1658 | padapter->pnetdev->name, new_ch, ch_offset); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1659 | |
| 1660 | spin_lock_bh(&pstapriv->asoc_list_lock); |
| 1661 | phead = &pstapriv->asoc_list; |
| 1662 | |
| 1663 | list_for_each(plist, phead) { |
| 1664 | psta = container_of(plist, struct sta_info, asoc_list); |
| 1665 | |
| 1666 | issue_action_spct_ch_switch23a (padapter, psta->hwaddr, new_ch, ch_offset); |
| 1667 | psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : (pstapriv->expire_to * 2); |
| 1668 | } |
| 1669 | spin_unlock_bh(&pstapriv->asoc_list_lock); |
| 1670 | |
| 1671 | issue_action_spct_ch_switch23a (padapter, bc_addr, new_ch, ch_offset); |
| 1672 | |
Heena Sirwani | f9800f8 | 2014-10-07 14:46:30 +0530 | [diff] [blame] | 1673 | return 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1674 | } |
| 1675 | |
| 1676 | int rtw_sta_flush23a(struct rtw_adapter *padapter) |
| 1677 | { |
| 1678 | struct list_head *phead, *plist, *ptmp; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1679 | struct sta_info *psta; |
| 1680 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1681 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1682 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 1683 | u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 1684 | u8 chk_alive_num = 0; |
Jes Sorensen | 6964213 | 2014-05-09 15:03:47 +0200 | [diff] [blame] | 1685 | struct sta_info *chk_alive_list[NUM_STA]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1686 | int i; |
| 1687 | |
Jes Sorensen | a790d58 | 2014-05-09 15:04:04 +0200 | [diff] [blame] | 1688 | DBG_8723A("%s(%s)\n", __func__, padapter->pnetdev->name); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1689 | |
Jes Sorensen | 6ec2627 | 2014-07-17 22:59:46 +0200 | [diff] [blame] | 1690 | if ((pmlmeinfo->state&0x03) != MSR_AP) |
Heena Sirwani | f9800f8 | 2014-10-07 14:46:30 +0530 | [diff] [blame] | 1691 | return 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1692 | |
| 1693 | spin_lock_bh(&pstapriv->asoc_list_lock); |
| 1694 | phead = &pstapriv->asoc_list; |
| 1695 | |
| 1696 | list_for_each_safe(plist, ptmp, phead) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1697 | psta = container_of(plist, struct sta_info, asoc_list); |
| 1698 | |
| 1699 | /* Remove sta from asoc_list */ |
| 1700 | list_del_init(&psta->asoc_list); |
| 1701 | pstapriv->asoc_list_cnt--; |
| 1702 | |
| 1703 | /* Keep sta for ap_free_sta23a() beyond this asoc_list loop */ |
Jes Sorensen | 6964213 | 2014-05-09 15:03:47 +0200 | [diff] [blame] | 1704 | chk_alive_list[chk_alive_num++] = psta; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1705 | } |
| 1706 | spin_unlock_bh(&pstapriv->asoc_list_lock); |
| 1707 | |
| 1708 | /* For each sta in chk_alive_list, call ap_free_sta23a */ |
Jes Sorensen | 6964213 | 2014-05-09 15:03:47 +0200 | [diff] [blame] | 1709 | for (i = 0; i < chk_alive_num; i++) |
| 1710 | ap_free_sta23a(padapter, chk_alive_list[i], true, |
| 1711 | WLAN_REASON_DEAUTH_LEAVING); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1712 | |
| 1713 | issue_deauth23a(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING); |
| 1714 | |
| 1715 | associated_clients_update23a(padapter, true); |
| 1716 | |
Heena Sirwani | f9800f8 | 2014-10-07 14:46:30 +0530 | [diff] [blame] | 1717 | return 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1718 | } |
| 1719 | |
| 1720 | /* called > TSR LEVEL for USB or SDIO Interface*/ |
| 1721 | void sta_info_update23a(struct rtw_adapter *padapter, struct sta_info *psta) |
| 1722 | { |
| 1723 | int flags = psta->flags; |
| 1724 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1725 | |
| 1726 | /* update wmm cap. */ |
| 1727 | if (WLAN_STA_WME&flags) |
| 1728 | psta->qos_option = 1; |
| 1729 | else |
| 1730 | psta->qos_option = 0; |
| 1731 | |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 1732 | if (pmlmepriv->qos_option == 0) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1733 | psta->qos_option = 0; |
| 1734 | |
| 1735 | /* update 802.11n ht cap. */ |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1736 | if (WLAN_STA_HT&flags) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1737 | psta->htpriv.ht_option = true; |
| 1738 | psta->qos_option = 1; |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1739 | } else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1740 | psta->htpriv.ht_option = false; |
| 1741 | } |
| 1742 | |
Jes Sorensen | 6a5f657 | 2014-06-09 15:16:07 +0200 | [diff] [blame] | 1743 | if (!pmlmepriv->htpriv.ht_option) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1744 | psta->htpriv.ht_option = false; |
| 1745 | |
| 1746 | update_sta_info23a_apmode23a(padapter, psta); |
| 1747 | } |
| 1748 | |
| 1749 | /* called >= TSR LEVEL for USB or SDIO Interface*/ |
| 1750 | void ap_sta_info_defer_update23a(struct rtw_adapter *padapter, struct sta_info *psta) |
| 1751 | { |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1752 | if (psta->state & _FW_LINKED) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1753 | /* add ratid */ |
| 1754 | add_RATid23a(padapter, psta, 0);/* DM_RATR_STA_INIT */ |
| 1755 | } |
| 1756 | } |
| 1757 | |
| 1758 | /* restore hw setting from sw data structures */ |
| 1759 | void rtw_ap_restore_network(struct rtw_adapter *padapter) |
| 1760 | { |
| 1761 | struct mlme_priv *mlmepriv = &padapter->mlmepriv; |
| 1762 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
Greg Donald | 8e3d161 | 2014-10-02 18:28:41 -0500 | [diff] [blame] | 1763 | struct sta_priv *pstapriv = &padapter->stapriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1764 | struct sta_info *psta; |
| 1765 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
| 1766 | struct list_head *phead, *plist, *ptmp; |
| 1767 | u8 chk_alive_num = 0; |
Jes Sorensen | 6964213 | 2014-05-09 15:03:47 +0200 | [diff] [blame] | 1768 | struct sta_info *chk_alive_list[NUM_STA]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1769 | int i; |
| 1770 | |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 1771 | rtw_setopmode_cmd23a(padapter, NL80211_IFTYPE_AP); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1772 | |
| 1773 | set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); |
| 1774 | |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 1775 | start_bss_network(padapter, (u8 *)&mlmepriv->cur_network.network); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1776 | |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 1777 | if (padapter->securitypriv.dot11PrivacyAlgrthm == |
| 1778 | WLAN_CIPHER_SUITE_TKIP || |
| 1779 | padapter->securitypriv.dot11PrivacyAlgrthm == |
| 1780 | WLAN_CIPHER_SUITE_CCMP) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1781 | /* restore group key, WEP keys is restored in ips_leave23a() */ |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 1782 | rtw_set_key23a(padapter, psecuritypriv, |
| 1783 | psecuritypriv->dot118021XGrpKeyid, 0); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1784 | } |
| 1785 | |
| 1786 | /* per sta pairwise key and settings */ |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 1787 | if (padapter->securitypriv.dot11PrivacyAlgrthm != |
| 1788 | WLAN_CIPHER_SUITE_TKIP && |
| 1789 | padapter->securitypriv.dot11PrivacyAlgrthm != |
| 1790 | WLAN_CIPHER_SUITE_CCMP) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1791 | return; |
| 1792 | } |
| 1793 | |
| 1794 | spin_lock_bh(&pstapriv->asoc_list_lock); |
| 1795 | |
| 1796 | phead = &pstapriv->asoc_list; |
| 1797 | |
| 1798 | list_for_each_safe(plist, ptmp, phead) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1799 | psta = container_of(plist, struct sta_info, asoc_list); |
| 1800 | |
Jes Sorensen | 6964213 | 2014-05-09 15:03:47 +0200 | [diff] [blame] | 1801 | chk_alive_list[chk_alive_num++] = psta; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1802 | } |
| 1803 | |
| 1804 | spin_unlock_bh(&pstapriv->asoc_list_lock); |
| 1805 | |
| 1806 | for (i = 0; i < chk_alive_num; i++) { |
Jes Sorensen | 6964213 | 2014-05-09 15:03:47 +0200 | [diff] [blame] | 1807 | psta = chk_alive_list[i]; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1808 | |
MihaelaGaman | adabff8 | 2014-09-14 12:56:43 +0300 | [diff] [blame] | 1809 | if (psta->state & _FW_LINKED) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1810 | Update_RA_Entry23a(padapter, psta); |
| 1811 | /* pairwise key */ |
| 1812 | rtw_setstakey_cmd23a(padapter, (unsigned char *)psta, true); |
| 1813 | } |
| 1814 | } |
| 1815 | } |
| 1816 | |
| 1817 | void start_ap_mode23a(struct rtw_adapter *padapter) |
| 1818 | { |
| 1819 | int i; |
| 1820 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1821 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1822 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1823 | struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; |
| 1824 | |
| 1825 | pmlmepriv->update_bcn = false; |
| 1826 | |
| 1827 | /* init_mlme_ap_info23a(padapter); */ |
| 1828 | pmlmeext->bstart_bss = false; |
| 1829 | |
| 1830 | pmlmepriv->num_sta_non_erp = 0; |
| 1831 | |
| 1832 | pmlmepriv->num_sta_no_short_slot_time = 0; |
| 1833 | |
| 1834 | pmlmepriv->num_sta_no_short_preamble = 0; |
| 1835 | |
| 1836 | pmlmepriv->num_sta_ht_no_gf = 0; |
| 1837 | pmlmepriv->num_sta_no_ht = 0; |
| 1838 | pmlmepriv->num_sta_ht_20mhz = 0; |
| 1839 | |
| 1840 | pmlmepriv->olbc = false; |
| 1841 | |
| 1842 | pmlmepriv->olbc_ht = false; |
| 1843 | |
| 1844 | pmlmepriv->ht_op_mode = 0; |
| 1845 | |
MihaelaGaman | adabff8 | 2014-09-14 12:56:43 +0300 | [diff] [blame] | 1846 | for (i = 0; i < NUM_STA; i++) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1847 | pstapriv->sta_aid[i] = NULL; |
| 1848 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1849 | /* for ACL */ |
| 1850 | INIT_LIST_HEAD(&pacl_list->acl_node_q.queue); |
| 1851 | pacl_list->num = 0; |
| 1852 | pacl_list->mode = 0; |
| 1853 | for (i = 0; i < NUM_ACL; i++) { |
| 1854 | INIT_LIST_HEAD(&pacl_list->aclnode[i].list); |
| 1855 | pacl_list->aclnode[i].valid = false; |
| 1856 | } |
| 1857 | } |
| 1858 | |
| 1859 | void stop_ap_mode23a(struct rtw_adapter *padapter) |
| 1860 | { |
| 1861 | struct list_head *phead, *plist, *ptmp; |
| 1862 | struct rtw_wlan_acl_node *paclnode; |
| 1863 | struct sta_info *psta = NULL; |
| 1864 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1865 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1866 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 1867 | struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; |
| 1868 | struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q; |
| 1869 | |
| 1870 | pmlmepriv->update_bcn = false; |
| 1871 | pmlmeext->bstart_bss = false; |
| 1872 | |
| 1873 | /* reset and init security priv , this can refine with rtw_reset_securitypriv23a */ |
| 1874 | memset((unsigned char *)&padapter->securitypriv, 0, sizeof (struct security_priv)); |
| 1875 | padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; |
| 1876 | padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; |
| 1877 | |
| 1878 | /* for ACL */ |
| 1879 | spin_lock_bh(&pacl_node_q->lock); |
| 1880 | phead = get_list_head(pacl_node_q); |
| 1881 | |
| 1882 | list_for_each_safe(plist, ptmp, phead) { |
| 1883 | paclnode = container_of(plist, struct rtw_wlan_acl_node, list); |
| 1884 | |
| 1885 | if (paclnode->valid == true) { |
| 1886 | paclnode->valid = false; |
| 1887 | |
| 1888 | list_del_init(&paclnode->list); |
| 1889 | |
| 1890 | pacl_list->num--; |
| 1891 | } |
| 1892 | } |
| 1893 | spin_unlock_bh(&pacl_node_q->lock); |
| 1894 | |
| 1895 | DBG_8723A("%s, free acl_node_queue, num =%d\n", __func__, pacl_list->num); |
| 1896 | |
| 1897 | rtw_sta_flush23a(padapter); |
| 1898 | |
| 1899 | /* free_assoc_sta_resources */ |
| 1900 | rtw_free_all_stainfo23a(padapter); |
| 1901 | |
| 1902 | psta = rtw_get_bcmc_stainfo23a(padapter); |
| 1903 | spin_lock_bh(&pstapriv->sta_hash_lock); |
| 1904 | rtw_free_stainfo23a(padapter, psta); |
| 1905 | spin_unlock_bh(&pstapriv->sta_hash_lock); |
| 1906 | |
| 1907 | rtw_init_bcmc_stainfo23a(padapter); |
| 1908 | |
| 1909 | rtw23a_free_mlme_priv_ie_data(pmlmepriv); |
| 1910 | } |