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