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