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