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