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