blob: 75ae2492699a0b738659aa149b1b79792d874d82 [file] [log] [blame]
Larry Finger5e93f352014-03-28 21:37:38 -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 ******************************************************************************/
15#define _RTW_AP_C_
16
17#include <osdep_service.h>
18#include <drv_types.h>
19#include <linux/ieee80211.h>
20#include <wifi.h>
Jes Sorensen1ec69342014-05-16 10:04:11 +020021#include <rtl8723a_cmd.h>
Jes Sorensendbe98492014-05-16 10:04:13 +020022#include <rtl8723a_hal.h>
Larry Finger5e93f352014-03-28 21:37:38 -050023
Larry Finger5e93f352014-03-28 21:37:38 -050024extern unsigned char WMM_OUI23A[];
25extern unsigned char WPS_OUI23A[];
26extern unsigned char P2P_OUI23A[];
Larry Finger5e93f352014-03-28 21:37:38 -050027
28void init_mlme_ap_info23a(struct rtw_adapter *padapter)
29{
30 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
31 struct sta_priv *pstapriv = &padapter->stapriv;
32 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
33
34 spin_lock_init(&pmlmepriv->bcn_update_lock);
35
36 /* for ACL */
37 _rtw_init_queue23a(&pacl_list->acl_node_q);
38
39 start_ap_mode23a(padapter);
40}
41
42void free_mlme_ap_info23a(struct rtw_adapter *padapter)
43{
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_flush23a(padapter);
54
Jes Sorensen6ec26272014-07-17 22:59:46 +020055 pmlmeinfo->state = MSR_NOLINK;
Larry Finger5e93f352014-03-28 21:37:38 -050056
57 /* free_assoc_sta_resources */
58 rtw_free_all_stainfo23a(padapter);
59
60 /* free bc/mc sta_info */
61 psta = rtw_get_bcmc_stainfo23a(padapter);
62 spin_lock_bh(&pstapriv->sta_hash_lock);
63 rtw_free_stainfo23a(padapter, psta);
64 spin_unlock_bh(&pstapriv->sta_hash_lock);
65}
66
67static void update_BCNTIM(struct rtw_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;
74 u8 *p, *dst_ie, *premainder_ie = NULL, *pbackup_remainder_ie = NULL;
Larry Fingera96ae6f2014-04-26 18:55:18 +020075 __le16 tim_bitmap_le;
Larry Finger5e93f352014-03-28 21:37:38 -050076 uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;
77
78 tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap);
79
Jes Sorensen1de65cc2014-06-24 15:03:30 +020080 p = rtw_get_ie23a(pie, WLAN_EID_TIM, &tim_ielen,
81 pnetwork_mlmeext->IELength);
MihaelaGamanadabff82014-09-14 12:56:43 +030082 if (p != NULL && tim_ielen > 0) {
Larry Finger5e93f352014-03-28 21:37:38 -050083 tim_ielen += 2;
84
85 premainder_ie = p+tim_ielen;
86
Tapasweni Pathak7d364292014-09-21 19:38:30 +053087 tim_ie_offset = (int)(p - pie);
Larry Finger5e93f352014-03-28 21:37:38 -050088
89 remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen;
90
91 /* append TIM IE from dst_ie offset */
92 dst_ie = p;
93 } else {
94 tim_ielen = 0;
95
Masanari Iida96b0a5b2014-07-22 23:42:45 +090096 /* calculate head_len */
Jes Sorensen1de65cc2014-06-24 15:03:30 +020097 offset = 0;
Larry Finger5e93f352014-03-28 21:37:38 -050098
99 /* get ssid_ie len */
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200100 p = rtw_get_ie23a(pie, WLAN_EID_SSID,
101 &tmp_len, pnetwork_mlmeext->IELength);
Larry Finger5e93f352014-03-28 21:37:38 -0500102 if (p != NULL)
103 offset += tmp_len+2;
104
105 /* get supported rates len */
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200106 p = rtw_get_ie23a(pie, WLAN_EID_SUPP_RATES,
107 &tmp_len, pnetwork_mlmeext->IELength);
Larry Finger5e93f352014-03-28 21:37:38 -0500108 if (p != NULL)
109 offset += tmp_len+2;
110
111 /* DS Parameter Set IE, len = 3 */
112 offset += 3;
113
114 premainder_ie = pie + offset;
115
116 remainder_ielen = pnetwork_mlmeext->IELength - offset - tim_ielen;
117
118 /* append TIM IE from offset */
119 dst_ie = pie + offset;
120 }
121
122 if (remainder_ielen > 0) {
123 pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_ATOMIC);
124 if (pbackup_remainder_ie && premainder_ie)
125 memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
126 }
127
MihaelaGamanadabff82014-09-14 12:56:43 +0300128 *dst_ie++ = WLAN_EID_TIM;
Larry Finger5e93f352014-03-28 21:37:38 -0500129
130 if ((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc))
131 tim_ielen = 5;
132 else
133 tim_ielen = 4;
134
MihaelaGamanadabff82014-09-14 12:56:43 +0300135 *dst_ie++ = tim_ielen;
Larry Finger5e93f352014-03-28 21:37:38 -0500136
MihaelaGamanadabff82014-09-14 12:56:43 +0300137 *dst_ie++ = 0;/* DTIM count */
138 *dst_ie++ = 1;/* DTIM period */
Larry Finger5e93f352014-03-28 21:37:38 -0500139
140 if (pstapriv->tim_bitmap & BIT(0))/* for bc/mc frames */
141 *dst_ie++ = BIT(0);/* bitmap ctrl */
142 else
143 *dst_ie++ = 0;
144
145 if (tim_ielen == 4) {
Greg Donald7e6646d2014-09-06 19:42:03 -0500146 *dst_ie++ = *(u8 *)&tim_bitmap_le;
Larry Finger5e93f352014-03-28 21:37:38 -0500147 } else if (tim_ielen == 5) {
148 memcpy(dst_ie, &tim_bitmap_le, 2);
MihaelaGamanadabff82014-09-14 12:56:43 +0300149 dst_ie += 2;
Larry Finger5e93f352014-03-28 21:37:38 -0500150 }
151
152 /* copy remainder IE */
153 if (pbackup_remainder_ie) {
154 memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen);
155
156 kfree(pbackup_remainder_ie);
157 }
158
159 offset = (uint)(dst_ie - pie);
160 pnetwork_mlmeext->IELength = offset + remainder_ielen;
161
162 set_tx_beacon_cmd23a(padapter);
163}
164
165static u8 chk_sta_is_alive(struct sta_info *psta)
166{
167 u8 ret = false;
168
169 if ((psta->sta_stats.last_rx_data_pkts +
170 psta->sta_stats.last_rx_ctrl_pkts) !=
171 (psta->sta_stats.rx_data_pkts + psta->sta_stats.rx_ctrl_pkts))
172 ret = true;
173
174 sta_update_last_rx_pkts(psta);
175
176 return ret;
177}
178
179void expire_timeout_chk23a(struct rtw_adapter *padapter)
180{
181 struct list_head *phead, *plist, *ptmp;
182 u8 updated = 0;
183 struct sta_info *psta;
184 struct sta_priv *pstapriv = &padapter->stapriv;
185 u8 chk_alive_num = 0;
Jes Sorensen69642132014-05-09 15:03:47 +0200186 struct sta_info *chk_alive_list[NUM_STA];
Larry Finger5e93f352014-03-28 21:37:38 -0500187 int i;
188
189 spin_lock_bh(&pstapriv->auth_list_lock);
190
191 phead = &pstapriv->auth_list;
192
193 /* check auth_queue */
194 list_for_each_safe(plist, ptmp, phead) {
195 psta = container_of(plist, struct sta_info, auth_list);
196
MihaelaGamanadabff82014-09-14 12:56:43 +0300197 if (psta->expire_to > 0) {
Larry Finger5e93f352014-03-28 21:37:38 -0500198 psta->expire_to--;
199 if (psta->expire_to == 0) {
200 list_del_init(&psta->auth_list);
201 pstapriv->auth_list_cnt--;
202
203 DBG_8723A("auth expire %pM\n", psta->hwaddr);
204
205 spin_unlock_bh(&pstapriv->auth_list_lock);
206
207 spin_lock_bh(&pstapriv->sta_hash_lock);
208 rtw_free_stainfo23a(padapter, psta);
209 spin_unlock_bh(&pstapriv->sta_hash_lock);
210
211 spin_lock_bh(&pstapriv->auth_list_lock);
212 }
213 }
214
215 }
216
217 spin_unlock_bh(&pstapriv->auth_list_lock);
218
219 spin_lock_bh(&pstapriv->asoc_list_lock);
220
221 phead = &pstapriv->asoc_list;
222
223 /* check asoc_queue */
224 list_for_each_safe(plist, ptmp, phead) {
225 psta = container_of(plist, struct sta_info, asoc_list);
226
227 if (chk_sta_is_alive(psta) || !psta->expire_to) {
228 psta->expire_to = pstapriv->expire_to;
229 psta->keep_alive_trycnt = 0;
230 } else {
231 psta->expire_to--;
232 }
233
234 if (psta->expire_to <= 0)
235 {
236 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
237
238 if (padapter->registrypriv.wifi_spec == 1)
239 {
240 psta->expire_to = pstapriv->expire_to;
241 continue;
242 }
243
244 if (psta->state & WIFI_SLEEP_STATE) {
245 if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) {
Masanari Iida96b0a5b2014-07-22 23:42:45 +0900246 /* to check if alive by another methods if station is at ps mode. */
Larry Finger5e93f352014-03-28 21:37:38 -0500247 psta->expire_to = pstapriv->expire_to;
248 psta->state |= WIFI_STA_ALIVE_CHK_STATE;
249
250 /* to update bcn with tim_bitmap for this station */
251 pstapriv->tim_bitmap |= CHKBIT(psta->aid);
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +0200252 update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
Larry Finger5e93f352014-03-28 21:37:38 -0500253
254 if (!pmlmeext->active_keep_alive_check)
255 continue;
256 }
257 }
258
259 if (pmlmeext->active_keep_alive_check) {
Jes Sorensen69642132014-05-09 15:03:47 +0200260 chk_alive_list[chk_alive_num++] = psta;
Larry Finger5e93f352014-03-28 21:37:38 -0500261 continue;
262 }
263
264 list_del_init(&psta->asoc_list);
265 pstapriv->asoc_list_cnt--;
266
267 DBG_8723A("asoc expire "MAC_FMT", state = 0x%x\n", MAC_ARG(psta->hwaddr), psta->state);
268 updated = ap_free_sta23a(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING);
269 } else {
270 /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */
271 if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt)
272 && padapter->xmitpriv.free_xmitframe_cnt < ((NR_XMITFRAME/pstapriv->asoc_list_cnt)/2)
273 ) {
274 DBG_8723A("%s sta:"MAC_FMT", sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", __func__,
275 MAC_ARG(psta->hwaddr),
276 psta->sleepq_len,
277 padapter->xmitpriv.free_xmitframe_cnt,
278 pstapriv->asoc_list_cnt);
279 wakeup_sta_to_xmit23a(padapter, psta);
280 }
281 }
282 }
283
284 spin_unlock_bh(&pstapriv->asoc_list_lock);
285
286 if (chk_alive_num) {
287
288 u8 backup_oper_channel = 0;
289 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
290 /* switch to correct channel of current network before issue keep-alive frames */
291 if (rtw_get_oper_ch23a(padapter) != pmlmeext->cur_channel) {
292 backup_oper_channel = rtw_get_oper_ch23a(padapter);
293 SelectChannel23a(padapter, pmlmeext->cur_channel);
Jes Sorensen69642132014-05-09 15:03:47 +0200294 }
Larry Finger5e93f352014-03-28 21:37:38 -0500295
296 /* issue null data to check sta alive*/
297 for (i = 0; i < chk_alive_num; i++) {
298
299 int ret = _FAIL;
300
Jes Sorensen69642132014-05-09 15:03:47 +0200301 psta = chk_alive_list[i];
Aybuke Ozdemirb34ba0c2014-09-28 17:22:36 +0300302 if (!(psta->state & _FW_LINKED))
Larry Finger5e93f352014-03-28 21:37:38 -0500303 continue;
304
305 if (psta->state & WIFI_SLEEP_STATE)
306 ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 1, 50);
307 else
308 ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 3, 50);
309
310 psta->keep_alive_trycnt++;
311 if (ret == _SUCCESS)
312 {
313 DBG_8723A("asoc check, sta(" MAC_FMT ") is alive\n", MAC_ARG(psta->hwaddr));
314 psta->expire_to = pstapriv->expire_to;
315 psta->keep_alive_trycnt = 0;
316 continue;
317 }
318 else if (psta->keep_alive_trycnt <= 3)
319 {
320 DBG_8723A("ack check for asoc expire, keep_alive_trycnt =%d\n", psta->keep_alive_trycnt);
321 psta->expire_to = 1;
322 continue;
323 }
324
325 psta->keep_alive_trycnt = 0;
326
327 DBG_8723A("asoc expire "MAC_FMT", state = 0x%x\n", MAC_ARG(psta->hwaddr), psta->state);
328 spin_lock_bh(&pstapriv->asoc_list_lock);
329 if (!list_empty(&psta->asoc_list)) {
330 list_del_init(&psta->asoc_list);
331 pstapriv->asoc_list_cnt--;
332 updated = ap_free_sta23a(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING);
333 }
334 spin_unlock_bh(&pstapriv->asoc_list_lock);
335
336 }
337
MihaelaGamanadabff82014-09-14 12:56:43 +0300338 if (backup_oper_channel > 0) /* back to the original operation channel */
Larry Finger5e93f352014-03-28 21:37:38 -0500339 SelectChannel23a(padapter, backup_oper_channel);
340}
341
342 associated_clients_update23a(padapter, updated);
343}
344
345void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_level)
346{
347 int i;
348 u8 rf_type;
349 u32 init_rate = 0;
350 unsigned char sta_band = 0, raid, shortGIrate = false;
351 unsigned char limit;
352 unsigned int tx_ra_bitmap = 0;
353 struct ht_priv *psta_ht = NULL;
354 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
Jes Sorensen52017952014-04-26 18:55:09 +0200355 struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network;
Larry Finger5e93f352014-03-28 21:37:38 -0500356
357 if (psta)
358 psta_ht = &psta->htpriv;
359 else
360 return;
361
362 if (!(psta->state & _FW_LINKED))
363 return;
364
365 /* b/g mode ra_bitmap */
MihaelaGamanadabff82014-09-14 12:56:43 +0300366 for (i = 0; i < sizeof(psta->bssrateset); i++)
Larry Finger5e93f352014-03-28 21:37:38 -0500367 {
368 if (psta->bssrateset[i])
369 tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f);
370 }
371 /* n mode ra_bitmap */
Jes Sorensenc2370e82014-04-09 23:20:53 +0200372 if (psta_ht->ht_option) {
373 rf_type = rtl8723a_get_rf_type(padapter);
374
Larry Finger5e93f352014-03-28 21:37:38 -0500375 if (rf_type == RF_2T2R)
376 limit = 16;/* 2R */
377 else
378 limit = 8;/* 1R */
379
Jes Sorensen5a4438932014-05-09 15:04:15 +0200380 for (i = 0; i < limit; i++) {
381 if (psta_ht->ht_cap.mcs.rx_mask[i / 8] & BIT(i % 8))
382 tx_ra_bitmap |= BIT(i + 12);
Larry Finger5e93f352014-03-28 21:37:38 -0500383 }
384
385 /* max short GI rate */
386 shortGIrate = psta_ht->sgi;
387 }
388
Jes Sorensen37cb9822014-05-21 09:37:40 +0200389 if (pcur_network->DSConfig > 14) {
Larry Finger5e93f352014-03-28 21:37:38 -0500390 /* 5G band */
391 if (tx_ra_bitmap & 0xffff000)
392 sta_band |= WIRELESS_11_5N | WIRELESS_11A;
393 else
394 sta_band |= WIRELESS_11A;
395 } else {
396 if (tx_ra_bitmap & 0xffff000)
397 sta_band |= WIRELESS_11_24N | WIRELESS_11G | WIRELESS_11B;
398 else if (tx_ra_bitmap & 0xff0)
Aybuke Ozdemirdd609252014-09-28 17:22:37 +0300399 sta_band |= WIRELESS_11G | WIRELESS_11B;
Larry Finger5e93f352014-03-28 21:37:38 -0500400 else
401 sta_band |= WIRELESS_11B;
402 }
403
404 psta->wireless_mode = sta_band;
405
406 raid = networktype_to_raid23a(sta_band);
407 init_rate = get_highest_rate_idx23a(tx_ra_bitmap&0x0fffffff)&0x3f;
408
409 if (psta->aid < NUM_STA)
410 {
411 u8 arg = 0;
412
413 arg = psta->mac_id&0x1f;
414
415 arg |= BIT(7);/* support entry 2~31 */
416
417 if (shortGIrate == true)
418 arg |= BIT(5);
419
420 tx_ra_bitmap |= ((raid<<28)&0xf0000000);
421
422 DBG_8723A("%s => mac_id:%d , raid:%d , bitmap = 0x%x, arg = "
423 "0x%x\n",
424 __func__, psta->mac_id, raid, tx_ra_bitmap, arg);
425
426 /* bitmap[0:27] = tx_rate_bitmap */
427 /* bitmap[28:31]= Rate Adaptive id */
428 /* arg[0:4] = macid */
429 /* arg[5] = Short GI */
Jes Sorensen1ec69342014-05-16 10:04:11 +0200430 rtl8723a_add_rateatid(padapter, tx_ra_bitmap, arg, rssi_level);
Larry Finger5e93f352014-03-28 21:37:38 -0500431
432 if (shortGIrate == true)
433 init_rate |= BIT(6);
434
435 /* set ra_id, init_rate */
436 psta->raid = raid;
437 psta->init_rate = init_rate;
438
439 }
440 else
441 {
442 DBG_8723A("station aid %d exceed the max number\n", psta->aid);
443 }
444}
445
446static void update_bmc_sta(struct rtw_adapter *padapter)
447{
448 u32 init_rate = 0;
449 unsigned char network_type, raid;
450 int i, supportRateNum = 0;
451 unsigned int tx_ra_bitmap = 0;
452 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
Jes Sorensen52017952014-04-26 18:55:09 +0200453 struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network;
Larry Finger5e93f352014-03-28 21:37:38 -0500454 struct sta_info *psta = rtw_get_bcmc_stainfo23a(padapter);
455
456 if (psta)
457 {
458 psta->aid = 0;/* default set to 0 */
459 psta->mac_id = psta->aid + 1;
460
461 psta->qos_option = 0;
462 psta->htpriv.ht_option = false;
463
464 psta->ieee8021x_blocked = 0;
465
Greg Donald7e6646d2014-09-06 19:42:03 -0500466 memset((void *)&psta->sta_stats, 0,
467 sizeof(struct stainfo_stats));
Larry Finger5e93f352014-03-28 21:37:38 -0500468
469 /* prepare for add_RATid23a */
470 supportRateNum = rtw_get_rateset_len23a((u8*)&pcur_network->SupportedRates);
471 network_type = rtw_check_network_type23a((u8*)&pcur_network->SupportedRates, supportRateNum, 1);
472
473 memcpy(psta->bssrateset, &pcur_network->SupportedRates, supportRateNum);
474 psta->bssratelen = supportRateNum;
475
476 /* b/g mode ra_bitmap */
MihaelaGamanadabff82014-09-14 12:56:43 +0300477 for (i = 0; i < supportRateNum; i++)
Larry Finger5e93f352014-03-28 21:37:38 -0500478 {
479 if (psta->bssrateset[i])
480 tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f);
481 }
482
Jes Sorensen37cb9822014-05-21 09:37:40 +0200483 if (pcur_network->DSConfig > 14) {
Larry Finger5e93f352014-03-28 21:37:38 -0500484 /* force to A mode. 5G doesn't support CCK rates */
485 network_type = WIRELESS_11A;
486 tx_ra_bitmap = 0x150; /* 6, 12, 24 Mbps */
487 } else {
488 /* force to b mode */
489 network_type = WIRELESS_11B;
490 tx_ra_bitmap = 0xf;
491 }
492
493 raid = networktype_to_raid23a(network_type);
494 init_rate = get_highest_rate_idx23a(tx_ra_bitmap&0x0fffffff)&0x3f;
495
496 /* ap mode */
Jes Sorensendbe98492014-05-16 10:04:13 +0200497 rtl8723a_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true);
Larry Finger5e93f352014-03-28 21:37:38 -0500498
499 {
500 u8 arg = 0;
501
502 arg = psta->mac_id&0x1f;
503
504 arg |= BIT(7);
505
506 tx_ra_bitmap |= ((raid<<28)&0xf0000000);
507
508 DBG_8723A("update_bmc_sta, mask = 0x%x, arg = 0x%x\n", tx_ra_bitmap, arg);
509
510 /* bitmap[0:27] = tx_rate_bitmap */
511 /* bitmap[28:31]= Rate Adaptive id */
512 /* arg[0:4] = macid */
513 /* arg[5] = Short GI */
Jes Sorensen1ec69342014-05-16 10:04:11 +0200514 rtl8723a_add_rateatid(padapter, tx_ra_bitmap, arg, 0);
Larry Finger5e93f352014-03-28 21:37:38 -0500515 }
516
517 /* set ra_id, init_rate */
518 psta->raid = raid;
519 psta->init_rate = init_rate;
520
Larry Finger5e93f352014-03-28 21:37:38 -0500521 spin_lock_bh(&psta->lock);
522 psta->state = _FW_LINKED;
523 spin_unlock_bh(&psta->lock);
524
525 }
526 else
527 {
528 DBG_8723A("add_RATid23a_bmc_sta error!\n");
529 }
530}
531
532/* notes: */
533/* AID: 1~MAX for sta and 0 for bc/mc in ap/adhoc mode */
534/* MAC_ID = AID+1 for sta in ap/adhoc mode */
535/* MAC_ID = 1 for bc/mc for sta/ap/adhoc */
536/* MAC_ID = 0 for bssid for sta/ap/adhoc */
537/* CAM_ID = 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */
538
539void update_sta_info23a_apmode23a(struct rtw_adapter *padapter, struct sta_info *psta)
540{
541 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
542 struct security_priv *psecuritypriv = &padapter->securitypriv;
543 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
544 struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv;
545 struct ht_priv *phtpriv_sta = &psta->htpriv;
546 /* set intf_tag to if1 */
547
548 psta->mac_id = psta->aid+1;
549 DBG_8723A("%s\n", __func__);
550
551 /* ap mode */
Jes Sorensendbe98492014-05-16 10:04:13 +0200552 rtl8723a_SetHalODMVar(padapter, HAL_ODM_STA_INFO, psta, true);
Larry Finger5e93f352014-03-28 21:37:38 -0500553
554 if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)
555 psta->ieee8021x_blocked = true;
556 else
557 psta->ieee8021x_blocked = false;
558
559 /* update sta's cap */
560
561 /* ERP */
562 VCS_update23a(padapter, psta);
563 /* HT related cap */
564 if (phtpriv_sta->ht_option)
565 {
566 /* check if sta supports rx ampdu */
567 phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable;
568
569 /* check if sta support s Short GI */
570 if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40))
571 phtpriv_sta->sgi = true;
572
573 /* bwmode */
574 if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40)) {
575 /* phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_40; */
576 phtpriv_sta->bwmode = pmlmeext->cur_bwmode;
577 phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset;
578
579 }
580
581 psta->qos_option = true;
582
583 }
584 else
585 {
586 phtpriv_sta->ampdu_enable = false;
587
588 phtpriv_sta->sgi = false;
589 phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20;
590 phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
591 }
592
593 /* Rx AMPDU */
594 send_delba23a(padapter, 0, psta->hwaddr);/* recipient */
595
596 /* TX AMPDU */
597 send_delba23a(padapter, 1, psta->hwaddr);/* originator */
598 phtpriv_sta->agg_enable_bitmap = 0x0;/* reset */
599 phtpriv_sta->candidate_tid_bitmap = 0x0;/* reset */
600
601 /* todo: init other variables */
602
Greg Donald7e6646d2014-09-06 19:42:03 -0500603 memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats));
Larry Finger5e93f352014-03-28 21:37:38 -0500604
605 spin_lock_bh(&psta->lock);
606 psta->state |= _FW_LINKED;
607 spin_unlock_bh(&psta->lock);
608}
609
610static void update_hw_ht_param(struct rtw_adapter *padapter)
611{
612 unsigned char max_AMPDU_len;
613 unsigned char min_MPDU_spacing;
614 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
615 struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
616
617 DBG_8723A("%s\n", __func__);
618
619 /* handle A-MPDU parameter field */
620 /*
621 AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k
622 AMPDU_para [4:2]:Min MPDU Start Spacing
623 */
Jes Sorensen65be27d2014-05-31 18:05:11 +0200624 max_AMPDU_len = pmlmeinfo->ht_cap.ampdu_params_info &
625 IEEE80211_HT_AMPDU_PARM_FACTOR;
Larry Finger5e93f352014-03-28 21:37:38 -0500626
Jes Sorensen65be27d2014-05-31 18:05:11 +0200627 min_MPDU_spacing = (pmlmeinfo->ht_cap.ampdu_params_info &
628 IEEE80211_HT_AMPDU_PARM_DENSITY) >> 2;
Larry Finger5e93f352014-03-28 21:37:38 -0500629
Jes Sorensendce610a2014-04-09 23:20:32 +0200630 rtl8723a_set_ampdu_min_space(padapter, min_MPDU_spacing);
631 rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len);
Larry Finger5e93f352014-03-28 21:37:38 -0500632
633 /* Config SM Power Save setting */
Jes Sorensen65be27d2014-05-31 18:05:11 +0200634 pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->ht_cap.cap_info) &
635 IEEE80211_HT_CAP_SM_PS) >> 2;
Larry Finger5e93f352014-03-28 21:37:38 -0500636 if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC)
637 DBG_8723A("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__);
638}
639
640static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf)
641{
Jes Sorensen731f9da2014-04-15 19:44:02 +0200642 const u8 *p;
Larry Finger5e93f352014-03-28 21:37:38 -0500643 u8 val8, cur_channel, cur_bwmode, cur_ch_offset;
644 u16 bcn_interval;
645 u32 acparm;
Larry Finger5e93f352014-03-28 21:37:38 -0500646 struct registry_priv *pregpriv = &padapter->registrypriv;
647 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
Greg Donald4e66cf02014-08-22 10:57:49 -0500648 struct security_priv *psecuritypriv = &padapter->securitypriv;
Jes Sorensen52017952014-04-26 18:55:09 +0200649 struct wlan_bssid_ex *pnetwork = &pmlmepriv->cur_network.network;
Larry Finger5e93f352014-03-28 21:37:38 -0500650 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
651 struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
652 struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network;
Jes Sorensen4dc5f8b2014-05-31 18:05:13 +0200653 struct ieee80211_ht_operation *pht_info = NULL;
Larry Finger5e93f352014-03-28 21:37:38 -0500654
Jes Sorensen143ced22014-06-19 11:37:22 +0200655 bcn_interval = (u16)pnetwork->beacon_interval;
Jes Sorensen37cb9822014-05-21 09:37:40 +0200656 cur_channel = pnetwork->DSConfig;
Larry Finger5e93f352014-03-28 21:37:38 -0500657 cur_bwmode = HT_CHANNEL_WIDTH_20;;
658 cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
659
660 /* check if there is wps ie, */
661 /* if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd, */
662 /* and at first time the security ie (RSN/WPA IE) will not include in beacon. */
Jes Sorensen715a8a72014-06-09 15:15:57 +0200663 if (NULL == cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
664 WLAN_OUI_TYPE_MICROSOFT_WPS,
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200665 pnetwork->IEs,
666 pnetwork->IELength))
Larry Finger5e93f352014-03-28 21:37:38 -0500667 pmlmeext->bstart_bss = true;
668
669 /* todo: update wmm, ht cap */
670 /* pmlmeinfo->WMM_enable; */
671 /* pmlmeinfo->HT_enable; */
Jes Sorensenbd8ad4a2014-05-09 15:03:21 +0200672 if (pmlmepriv->qos_option)
Larry Finger5e93f352014-03-28 21:37:38 -0500673 pmlmeinfo->WMM_enable = true;
674 if (pmlmepriv->htpriv.ht_option) {
675 pmlmeinfo->WMM_enable = true;
676 pmlmeinfo->HT_enable = true;
677
678 update_hw_ht_param(padapter);
679 }
680
681 if (pmlmepriv->cur_network.join_res != true) {
682 /* setting only at first time */
683 /* WEP Key will be set before this function, do not clear CAM. */
Jes Sorensen9e3d6df2014-05-21 09:37:34 +0200684 if (psecuritypriv->dot11PrivacyAlgrthm !=
685 WLAN_CIPHER_SUITE_WEP40 &&
686 psecuritypriv->dot11PrivacyAlgrthm !=
687 WLAN_CIPHER_SUITE_WEP104)
Larry Finger5e93f352014-03-28 21:37:38 -0500688 flush_all_cam_entry23a(padapter); /* clear CAM */
689 }
690
691 /* set MSR to AP_Mode */
Jes Sorensen6ec26272014-07-17 22:59:46 +0200692 rtl8723a_set_media_status(padapter, MSR_AP);
Larry Finger5e93f352014-03-28 21:37:38 -0500693
694 /* Set BSSID REG */
Jes Sorensen38dd10b2014-04-09 23:20:20 +0200695 hw_var_set_bssid(padapter, pnetwork->MacAddress);
Larry Finger5e93f352014-03-28 21:37:38 -0500696
697 /* Set EDCA param reg */
698 acparm = 0x002F3217; /* VO */
Jes Sorensen2487205e2014-04-09 23:20:30 +0200699 rtl8723a_set_ac_param_vo(padapter, acparm);
Larry Finger5e93f352014-03-28 21:37:38 -0500700 acparm = 0x005E4317; /* VI */
Jes Sorensen2487205e2014-04-09 23:20:30 +0200701 rtl8723a_set_ac_param_vi(padapter, acparm);
Larry Finger5e93f352014-03-28 21:37:38 -0500702 acparm = 0x005ea42b;
Jes Sorensen2487205e2014-04-09 23:20:30 +0200703 rtl8723a_set_ac_param_be(padapter, acparm);
Larry Finger5e93f352014-03-28 21:37:38 -0500704 acparm = 0x0000A444; /* BK */
Jes Sorensen2487205e2014-04-09 23:20:30 +0200705 rtl8723a_set_ac_param_bk(padapter, acparm);
Larry Finger5e93f352014-03-28 21:37:38 -0500706
707 /* Set Security */
Jes Sorensenb8e99162014-04-09 23:20:27 +0200708 val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ?
MihaelaGamanadabff82014-09-14 12:56:43 +0300709 0xcc : 0xcf;
Jes Sorensenb8e99162014-04-09 23:20:27 +0200710 rtl8723a_set_sec_cfg(padapter, val8);
Larry Finger5e93f352014-03-28 21:37:38 -0500711
712 /* Beacon Control related register */
Jes Sorensen477f0082014-04-09 23:20:23 +0200713 rtl8723a_set_beacon_interval(padapter, bcn_interval);
Larry Finger5e93f352014-03-28 21:37:38 -0500714
715 UpdateBrateTbl23a(padapter, pnetwork->SupportedRates);
Jes Sorensenfa2e5202014-04-09 23:20:18 +0200716 HalSetBrateCfg23a(padapter, pnetwork->SupportedRates);
Larry Finger5e93f352014-03-28 21:37:38 -0500717
718 if (!pmlmepriv->cur_network.join_res) {
719 /* setting only at first time */
720
721 /* disable dynamic functions, such as high power, DIG */
722
723 /* turn on all dynamic functions */
Jes Sorensen585eefb2014-04-09 23:20:43 +0200724 rtl8723a_odm_support_ability_set(padapter,
725 DYNAMIC_ALL_FUNC_ENABLE);
Larry Finger5e93f352014-03-28 21:37:38 -0500726 }
727 /* set channel, bwmode */
Jes Sorensenc164bcf2014-05-21 09:37:41 +0200728
Jes Sorensen68e6c792014-06-24 15:03:29 +0200729 p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pnetwork->IEs,
730 pnetwork->IELength);
Jes Sorensen731f9da2014-04-15 19:44:02 +0200731 if (p && p[1]) {
Jes Sorensen4dc5f8b2014-05-31 18:05:13 +0200732 pht_info = (struct ieee80211_ht_operation *)(p + 2);
Larry Finger5e93f352014-03-28 21:37:38 -0500733
Jes Sorensen4dc5f8b2014-05-31 18:05:13 +0200734 if (pregpriv->cbw40_enable && pht_info->ht_param &
735 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY) {
Larry Finger5e93f352014-03-28 21:37:38 -0500736 /* switch to the 40M Hz mode */
737 cur_bwmode = HT_CHANNEL_WIDTH_40;
Jes Sorensen4dc5f8b2014-05-31 18:05:13 +0200738 switch (pht_info->ht_param &
739 IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
740 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
Jes Sorensen731f9da2014-04-15 19:44:02 +0200741 /* pmlmeext->cur_ch_offset =
742 HAL_PRIME_CHNL_OFFSET_LOWER; */
Larry Finger5e93f352014-03-28 21:37:38 -0500743 cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER;
744 break;
Jes Sorensen4dc5f8b2014-05-31 18:05:13 +0200745 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
Larry Finger5e93f352014-03-28 21:37:38 -0500746 cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER;
747 break;
748 default:
749 cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
750 break;
751 }
752 }
753 }
754 /* TODO: need to judge the phy parameters on concurrent mode for single phy */
755 set_channel_bwmode23a(padapter, cur_channel, cur_ch_offset, cur_bwmode);
756
757 DBG_8723A("CH =%d, BW =%d, offset =%d\n", cur_channel, cur_bwmode,
758 cur_ch_offset);
759
760 pmlmeext->cur_channel = cur_channel;
761 pmlmeext->cur_bwmode = cur_bwmode;
762 pmlmeext->cur_ch_offset = cur_ch_offset;
763 pmlmeext->cur_wireless_mode = pmlmepriv->cur_network.network_type;
764
765 /* update cur_wireless_mode */
766 update_wireless_mode23a(padapter);
767
Masanari Iida96b0a5b2014-07-22 23:42:45 +0900768 /* update capability after cur_wireless_mode updated */
Jes Sorensena94e12b2014-06-19 11:37:34 +0200769 update_capinfo23a(padapter, pnetwork->capability);
Larry Finger5e93f352014-03-28 21:37:38 -0500770
771 /* let pnetwork_mlmeext == pnetwork_mlme. */
772 memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length);
773
Larry Finger5e93f352014-03-28 21:37:38 -0500774 if (pmlmeext->bstart_bss) {
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +0200775 update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
Larry Finger5e93f352014-03-28 21:37:38 -0500776
777 /* issue beacon frame */
778 if (send_beacon23a(padapter) == _FAIL)
779 DBG_8723A("issue_beacon23a, fail!\n");
780 }
781
782 /* update bc/mc sta_info */
783 update_bmc_sta(padapter);
784}
785
Jes Sorensenfb5fd462014-06-24 15:03:20 +0200786int rtw_check_beacon_data23a(struct rtw_adapter *padapter,
787 struct ieee80211_mgmt *mgmt, unsigned int len)
Larry Finger5e93f352014-03-28 21:37:38 -0500788{
789 int ret = _SUCCESS;
790 u8 *p;
791 u8 *pHT_caps_ie = NULL;
792 u8 *pHT_info_ie = NULL;
793 struct sta_info *psta = NULL;
Jes Sorensen51a26d22014-06-24 15:03:21 +0200794 u16 ht_cap = false;
Larry Finger5e93f352014-03-28 21:37:38 -0500795 uint ie_len = 0;
796 int group_cipher, pairwise_cipher;
797 u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX];
798 int supportRateNum = 0;
Larry Finger5e93f352014-03-28 21:37:38 -0500799 u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01};
800 struct registry_priv *pregistrypriv = &padapter->registrypriv;
801 struct security_priv *psecuritypriv = &padapter->securitypriv;
802 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
803 struct wlan_bssid_ex *pbss_network = &pmlmepriv->cur_network.network;
804 u8 *ie = pbss_network->IEs;
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200805 u8 *pbuf = mgmt->u.beacon.variable;
806 len -= offsetof(struct ieee80211_mgmt, u.beacon.variable);
Larry Finger5e93f352014-03-28 21:37:38 -0500807 /* SSID */
808 /* Supported rates */
809 /* DS Params */
810 /* WLAN_EID_COUNTRY */
811 /* ERP Information element */
812 /* Extended supported rates */
813 /* WPA/WPA2 */
814 /* Wi-Fi Wireless Multimedia Extensions */
815 /* ht_capab, ht_oper */
816 /* WPS IE */
817
818 DBG_8723A("%s, len =%d\n", __func__, len);
819
820 if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
821 return _FAIL;
822
Jes Sorensen8282aeb2014-04-26 18:54:53 +0200823 if (len > MAX_IE_SZ)
Larry Finger5e93f352014-03-28 21:37:38 -0500824 return _FAIL;
825
826 pbss_network->IELength = len;
827
828 memset(ie, 0, MAX_IE_SZ);
829
830 memcpy(ie, pbuf, pbss_network->IELength);
831
Jes Sorensenefc71442014-05-21 09:37:26 +0200832 if (pbss_network->ifmode != NL80211_IFTYPE_AP &&
833 pbss_network->ifmode != NL80211_IFTYPE_P2P_GO)
Larry Finger5e93f352014-03-28 21:37:38 -0500834 return _FAIL;
835
836 pbss_network->Rssi = 0;
837
838 memcpy(pbss_network->MacAddress, myid(&padapter->eeprompriv), ETH_ALEN);
839
Larry Finger5e93f352014-03-28 21:37:38 -0500840 /* SSID */
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200841 p = rtw_get_ie23a(ie, WLAN_EID_SSID, &ie_len, pbss_network->IELength);
Larry Finger5e93f352014-03-28 21:37:38 -0500842 if (p && ie_len > 0) {
843 memset(&pbss_network->Ssid, 0, sizeof(struct cfg80211_ssid));
844 memcpy(pbss_network->Ssid.ssid, (p + 2), ie_len);
845 pbss_network->Ssid.ssid_len = ie_len;
846 }
847
Masanari Iida96b0a5b2014-07-22 23:42:45 +0900848 /* channel */
Larry Finger5e93f352014-03-28 21:37:38 -0500849 channel = 0;
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200850 p = rtw_get_ie23a(ie, WLAN_EID_DS_PARAMS, &ie_len,
851 pbss_network->IELength);
Larry Finger5e93f352014-03-28 21:37:38 -0500852 if (p && ie_len > 0)
853 channel = *(p + 2);
854
Jes Sorensen37cb9822014-05-21 09:37:40 +0200855 pbss_network->DSConfig = channel;
Larry Finger5e93f352014-03-28 21:37:38 -0500856
857 memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX);
858 /* get supported rates */
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200859 p = rtw_get_ie23a(ie, WLAN_EID_SUPP_RATES, &ie_len,
860 pbss_network->IELength);
Larry Finger5e93f352014-03-28 21:37:38 -0500861 if (p) {
862 memcpy(supportRate, p+2, ie_len);
863 supportRateNum = ie_len;
864 }
865
866 /* get ext_supported rates */
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200867 p = rtw_get_ie23a(ie, WLAN_EID_EXT_SUPP_RATES,
868 &ie_len, pbss_network->IELength);
Larry Finger5e93f352014-03-28 21:37:38 -0500869 if (p) {
870 memcpy(supportRate+supportRateNum, p+2, ie_len);
871 supportRateNum += ie_len;
872 }
873
874 network_type = rtw_check_network_type23a(supportRate,
875 supportRateNum, channel);
876
877 rtw_set_supported_rate23a(pbss_network->SupportedRates, network_type);
878
879 /* parsing ERP_IE */
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200880 p = rtw_get_ie23a(ie, WLAN_EID_ERP_INFO, &ie_len,
881 pbss_network->IELength);
Larry Finger5e93f352014-03-28 21:37:38 -0500882 if (p && ie_len > 0)
Jes Sorensenb171da32014-05-21 09:37:42 +0200883 ERP_IE_handler23a(padapter, p);
Larry Finger5e93f352014-03-28 21:37:38 -0500884
885 /* update privacy/security */
Jes Sorensen51a26d22014-06-24 15:03:21 +0200886 if (pbss_network->capability & BIT(4))
Larry Finger5e93f352014-03-28 21:37:38 -0500887 pbss_network->Privacy = 1;
888 else
889 pbss_network->Privacy = 0;
890
891 psecuritypriv->wpa_psk = 0;
892
893 /* wpa2 */
894 group_cipher = 0; pairwise_cipher = 0;
Jes Sorensen9e3d6df2014-05-21 09:37:34 +0200895 psecuritypriv->wpa2_group_cipher = 0;
896 psecuritypriv->wpa2_pairwise_cipher = 0;
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200897 p = rtw_get_ie23a(ie, WLAN_EID_RSN, &ie_len,
898 pbss_network->IELength);
Larry Finger5e93f352014-03-28 21:37:38 -0500899 if (p && ie_len > 0) {
900 if (rtw_parse_wpa2_ie23a(p, ie_len+2, &group_cipher,
901 &pairwise_cipher, NULL) == _SUCCESS) {
902 psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
903
904 psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */
905 psecuritypriv->wpa_psk |= BIT(1);
906
907 psecuritypriv->wpa2_group_cipher = group_cipher;
908 psecuritypriv->wpa2_pairwise_cipher = pairwise_cipher;
909 }
910 }
911
912 /* wpa */
913 ie_len = 0;
914 group_cipher = 0;
915 pairwise_cipher = 0;
Jes Sorensen9e3d6df2014-05-21 09:37:34 +0200916 psecuritypriv->wpa_group_cipher = 0;
917 psecuritypriv->wpa_pairwise_cipher = 0;
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200918 for (p = ie; ;p += (ie_len + 2)) {
Jes Sorensen9300c942014-04-15 19:43:21 +0200919 p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len,
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200920 pbss_network->IELength - (ie_len + 2));
Jes Sorensen819d1812014-04-26 18:55:44 +0200921 if ((p) && (!memcmp(p+2, RTW_WPA_OUI23A_TYPE, 4))) {
Larry Finger5e93f352014-03-28 21:37:38 -0500922 if (rtw_parse_wpa_ie23a(p, ie_len+2, &group_cipher,
923 &pairwise_cipher, NULL) == _SUCCESS) {
924 psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X;
925
926 /* psk, todo:802.1x */
927 psecuritypriv->dot8021xalg = 1;
928
929 psecuritypriv->wpa_psk |= BIT(0);
930
931 psecuritypriv->wpa_group_cipher = group_cipher;
932 psecuritypriv->wpa_pairwise_cipher = pairwise_cipher;
933 }
934 break;
935 }
936
937 if ((p == NULL) || (ie_len == 0))
938 break;
939 }
940
941 /* wmm */
942 ie_len = 0;
Jes Sorensenbd8ad4a2014-05-09 15:03:21 +0200943 pmlmepriv->qos_option = 0;
Larry Finger5e93f352014-03-28 21:37:38 -0500944 if (pregistrypriv->wmm_enable) {
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200945 for (p = ie; ;p += (ie_len + 2)) {
Jes Sorensen9300c942014-04-15 19:43:21 +0200946 p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len,
Larry Finger5e93f352014-03-28 21:37:38 -0500947 (pbss_network->IELength -
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200948 (ie_len + 2)));
Larry Finger5e93f352014-03-28 21:37:38 -0500949 if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) {
Jes Sorensenbd8ad4a2014-05-09 15:03:21 +0200950 pmlmepriv->qos_option = 1;
Larry Finger5e93f352014-03-28 21:37:38 -0500951
952 *(p+8) |= BIT(7);/* QoS Info, support U-APSD */
953
954 /* disable all ACM bits since the WMM admission
955 * control is not supported
956 */
957 *(p + 10) &= ~BIT(4); /* BE */
958 *(p + 14) &= ~BIT(4); /* BK */
959 *(p + 18) &= ~BIT(4); /* VI */
960 *(p + 22) &= ~BIT(4); /* VO */
961 break;
962 }
963 if ((p == NULL) || (ie_len == 0))
964 break;
965 }
966 }
967 /* parsing HT_CAP_IE */
Jes Sorensen1de65cc2014-06-24 15:03:30 +0200968 p = rtw_get_ie23a(ie, WLAN_EID_HT_CAPABILITY, &ie_len,
969 pbss_network->IELength);
Larry Finger5e93f352014-03-28 21:37:38 -0500970 if (p && ie_len > 0) {
971 u8 rf_type;
972
973 struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap *)(p+2);
974
975 pHT_caps_ie = p;
976
977 ht_cap = true;
978 network_type |= WIRELESS_11_24N;
979
Jes Sorensenc2370e82014-04-09 23:20:53 +0200980 rf_type = rtl8723a_get_rf_type(padapter);
Larry Finger5e93f352014-03-28 21:37:38 -0500981
982 if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) ||
983 (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP))
984 pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07<<2));
985 else
986 pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY&0x00);
987
988 /* set Max Rx AMPDU size to 64K */
989 pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_FACTOR & 0x03);
990
991 if (rf_type == RF_1T1R) {
992 pht_cap->mcs.rx_mask[0] = 0xff;
993 pht_cap->mcs.rx_mask[1] = 0x0;
994 }
995
996 memcpy(&pmlmepriv->htpriv.ht_cap, p+2, ie_len);
997 }
998
999 /* parsing HT_INFO_IE */
Jes Sorensen1de65cc2014-06-24 15:03:30 +02001000 p = rtw_get_ie23a(ie, WLAN_EID_HT_OPERATION, &ie_len,
1001 pbss_network->IELength);
Larry Finger5e93f352014-03-28 21:37:38 -05001002 if (p && ie_len > 0)
1003 pHT_info_ie = p;
1004
Larry Finger5e93f352014-03-28 21:37:38 -05001005 pmlmepriv->cur_network.network_type = network_type;
1006
1007 pmlmepriv->htpriv.ht_option = false;
1008
1009 /* ht_cap */
1010 if (pregistrypriv->ht_enable && ht_cap) {
1011 pmlmepriv->htpriv.ht_option = true;
Jes Sorensenbd8ad4a2014-05-09 15:03:21 +02001012 pmlmepriv->qos_option = 1;
Larry Finger5e93f352014-03-28 21:37:38 -05001013
1014 if (pregistrypriv->ampdu_enable == 1)
1015 pmlmepriv->htpriv.ampdu_enable = true;
1016
Jes Sorensenb171da32014-05-21 09:37:42 +02001017 HT_caps_handler23a(padapter, pHT_caps_ie);
Larry Finger5e93f352014-03-28 21:37:38 -05001018
Jes Sorensenb171da32014-05-21 09:37:42 +02001019 HT_info_handler23a(padapter, pHT_info_ie);
Larry Finger5e93f352014-03-28 21:37:38 -05001020 }
1021
Jes Sorensen52017952014-04-26 18:55:09 +02001022 pbss_network->Length = get_wlan_bssid_ex_sz(pbss_network);
Larry Finger5e93f352014-03-28 21:37:38 -05001023
1024 /* issue beacon to start bss network */
Greg Donald7e6646d2014-09-06 19:42:03 -05001025 start_bss_network(padapter, (u8 *)pbss_network);
Larry Finger5e93f352014-03-28 21:37:38 -05001026
1027 /* alloc sta_info for ap itself */
1028 psta = rtw_get_stainfo23a(&padapter->stapriv, pbss_network->MacAddress);
1029 if (!psta) {
Jes Sorensen6e8bc712014-05-09 15:03:49 +02001030 psta = rtw_alloc_stainfo23a(&padapter->stapriv,
1031 pbss_network->MacAddress,
1032 GFP_KERNEL);
Larry Finger5e93f352014-03-28 21:37:38 -05001033 if (!psta)
1034 return _FAIL;
1035 }
1036 /* fix bug of flush_cam_entry at STOP AP mode */
1037 psta->state |= WIFI_AP_STATE;
1038 rtw_indicate_connect23a(padapter);
1039
1040 /* for check if already set beacon */
1041 pmlmepriv->cur_network.join_res = true;
1042
1043 return ret;
1044}
1045
1046void rtw_set_macaddr_acl23a(struct rtw_adapter *padapter, int mode)
1047{
1048 struct sta_priv *pstapriv = &padapter->stapriv;
1049 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
1050
1051 DBG_8723A("%s, mode =%d\n", __func__, mode);
1052
1053 pacl_list->mode = mode;
1054}
1055
1056int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr)
1057{
1058 struct list_head *plist, *phead;
1059 u8 added = false;
1060 int i, ret = 0;
1061 struct rtw_wlan_acl_node *paclnode;
1062 struct sta_priv *pstapriv = &padapter->stapriv;
1063 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
1064 struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q;
1065
1066 DBG_8723A("%s(acl_num =%d) =" MAC_FMT "\n", __func__, pacl_list->num, MAC_ARG(addr));
1067
1068 if ((NUM_ACL-1) < pacl_list->num)
1069 return -1;
1070
1071 spin_lock_bh(&pacl_node_q->lock);
1072
1073 phead = get_list_head(pacl_node_q);
1074
1075 list_for_each(plist, phead) {
1076 paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
1077
1078 if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
1079 if (paclnode->valid == true) {
1080 added = true;
1081 DBG_8723A("%s, sta has been added\n", __func__);
1082 break;
1083 }
1084 }
1085 }
1086
1087 spin_unlock_bh(&pacl_node_q->lock);
1088
1089 if (added)
1090 return ret;
1091
1092 spin_lock_bh(&pacl_node_q->lock);
1093
1094 for (i = 0; i < NUM_ACL; i++) {
1095 paclnode = &pacl_list->aclnode[i];
1096
1097 if (!paclnode->valid) {
1098 INIT_LIST_HEAD(&paclnode->list);
1099
1100 memcpy(paclnode->addr, addr, ETH_ALEN);
1101
1102 paclnode->valid = true;
1103
1104 list_add_tail(&paclnode->list, get_list_head(pacl_node_q));
1105
1106 pacl_list->num++;
1107
1108 break;
1109 }
1110 }
1111
1112 DBG_8723A("%s, acl_num =%d\n", __func__, pacl_list->num);
1113
1114 spin_unlock_bh(&pacl_node_q->lock);
1115 return ret;
1116}
1117
1118int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr)
1119{
1120 struct list_head *plist, *phead, *ptmp;
1121 struct rtw_wlan_acl_node *paclnode;
1122 struct sta_priv *pstapriv = &padapter->stapriv;
1123 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
1124 struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q;
Larry Finger5e93f352014-03-28 21:37:38 -05001125
1126 DBG_8723A("%s(acl_num =%d) = %pM\n", __func__, pacl_list->num, addr);
1127
1128 spin_lock_bh(&pacl_node_q->lock);
1129
1130 phead = get_list_head(pacl_node_q);
1131
1132 list_for_each_safe(plist, ptmp, phead) {
1133 paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
1134
1135 if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
1136 if (paclnode->valid) {
1137 paclnode->valid = false;
1138
1139 list_del_init(&paclnode->list);
1140
1141 pacl_list->num--;
1142 }
1143 }
1144 }
1145
1146 spin_unlock_bh(&pacl_node_q->lock);
1147
1148 DBG_8723A("%s, acl_num =%d\n", __func__, pacl_list->num);
1149
Heena Sirwanif9800f82014-10-07 14:46:30 +05301150 return 0;
Larry Finger5e93f352014-03-28 21:37:38 -05001151}
1152
1153static void update_bcn_fixed_ie(struct rtw_adapter *padapter)
1154{
1155 DBG_8723A("%s\n", __func__);
1156}
1157
1158static void update_bcn_erpinfo_ie(struct rtw_adapter *padapter)
1159{
1160 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1161 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1162 struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
1163 struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network;
1164 unsigned char *p, *ie = pnetwork->IEs;
1165 u32 len = 0;
1166
1167 DBG_8723A("%s, ERP_enable =%d\n", __func__, pmlmeinfo->ERP_enable);
1168
1169 if (!pmlmeinfo->ERP_enable)
1170 return;
1171
1172 /* parsing ERP_IE */
Jes Sorensen1de65cc2014-06-24 15:03:30 +02001173 p = rtw_get_ie23a(ie, WLAN_EID_ERP_INFO, &len, pnetwork->IELength);
Jes Sorensenb171da32014-05-21 09:37:42 +02001174 if (p && len > 0) {
Larry Finger5e93f352014-03-28 21:37:38 -05001175 if (pmlmepriv->num_sta_non_erp == 1)
Jes Sorensenb171da32014-05-21 09:37:42 +02001176 p[2] |= WLAN_ERP_NON_ERP_PRESENT |
Larry Finger5e93f352014-03-28 21:37:38 -05001177 WLAN_ERP_USE_PROTECTION;
1178 else
Jes Sorensenb171da32014-05-21 09:37:42 +02001179 p[2] &= ~(WLAN_ERP_NON_ERP_PRESENT |
1180 WLAN_ERP_USE_PROTECTION);
Larry Finger5e93f352014-03-28 21:37:38 -05001181
1182 if (pmlmepriv->num_sta_no_short_preamble > 0)
Jes Sorensenb171da32014-05-21 09:37:42 +02001183 p[2] |= WLAN_ERP_BARKER_PREAMBLE;
Larry Finger5e93f352014-03-28 21:37:38 -05001184 else
Jes Sorensenb171da32014-05-21 09:37:42 +02001185 p[2] &= ~(WLAN_ERP_BARKER_PREAMBLE);
Larry Finger5e93f352014-03-28 21:37:38 -05001186
Jes Sorensenb171da32014-05-21 09:37:42 +02001187 ERP_IE_handler23a(padapter, p);
Larry Finger5e93f352014-03-28 21:37:38 -05001188 }
1189}
1190
1191static void update_bcn_htcap_ie(struct rtw_adapter *padapter)
1192{
1193 DBG_8723A("%s\n", __func__);
1194}
1195
1196static void update_bcn_htinfo_ie(struct rtw_adapter *padapter)
1197{
1198 DBG_8723A("%s\n", __func__);
1199}
1200
1201static void update_bcn_rsn_ie(struct rtw_adapter *padapter)
1202{
1203 DBG_8723A("%s\n", __func__);
1204}
1205
1206static void update_bcn_wpa_ie(struct rtw_adapter *padapter)
1207{
1208 DBG_8723A("%s\n", __func__);
1209}
1210
1211static void update_bcn_wmm_ie(struct rtw_adapter *padapter)
1212{
1213 DBG_8723A("%s\n", __func__);
1214}
1215
1216static void update_bcn_wps_ie(struct rtw_adapter *padapter)
1217{
Larry Finger5e93f352014-03-28 21:37:38 -05001218 DBG_8723A("%s\n", __func__);
Larry Finger5e93f352014-03-28 21:37:38 -05001219}
1220
1221static void update_bcn_p2p_ie(struct rtw_adapter *padapter)
1222{
1223}
1224
1225static void update_bcn_vendor_spec_ie(struct rtw_adapter *padapter, u8*oui)
1226{
1227 DBG_8723A("%s\n", __func__);
1228
Jes Sorensen7964eba02014-04-15 19:44:11 +02001229 if (!memcmp(RTW_WPA_OUI23A_TYPE, oui, 4))
Larry Finger5e93f352014-03-28 21:37:38 -05001230 update_bcn_wpa_ie(padapter);
Larry Finger5e93f352014-03-28 21:37:38 -05001231 else if (!memcmp(WMM_OUI23A, oui, 4))
Larry Finger5e93f352014-03-28 21:37:38 -05001232 update_bcn_wmm_ie(padapter);
Larry Finger5e93f352014-03-28 21:37:38 -05001233 else if (!memcmp(WPS_OUI23A, oui, 4))
Larry Finger5e93f352014-03-28 21:37:38 -05001234 update_bcn_wps_ie(padapter);
Larry Finger5e93f352014-03-28 21:37:38 -05001235 else if (!memcmp(P2P_OUI23A, oui, 4))
Larry Finger5e93f352014-03-28 21:37:38 -05001236 update_bcn_p2p_ie(padapter);
Larry Finger5e93f352014-03-28 21:37:38 -05001237 else
Larry Finger5e93f352014-03-28 21:37:38 -05001238 DBG_8723A("unknown OUI type!\n");
Larry Finger5e93f352014-03-28 21:37:38 -05001239}
1240
1241void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx)
1242{
1243 struct mlme_priv *pmlmepriv;
1244 struct mlme_ext_priv *pmlmeext;
1245 /* struct mlme_ext_info *pmlmeinfo; */
1246
1247 /* DBG_8723A("%s\n", __func__); */
1248
1249 if (!padapter)
1250 return;
1251
1252 pmlmepriv = &padapter->mlmepriv;
1253 pmlmeext = &padapter->mlmeextpriv;
1254 /* pmlmeinfo = &pmlmeext->mlmext_info; */
1255
1256 if (false == pmlmeext->bstart_bss)
1257 return;
1258
1259 spin_lock_bh(&pmlmepriv->bcn_update_lock);
1260
1261 switch (ie_id)
1262 {
Jes Sorensenb54e8802014-04-09 23:20:52 +02001263 case 0xFF:
1264 /* 8: TimeStamp, 2: Beacon Interval 2:Capability */
1265 update_bcn_fixed_ie(padapter);
1266 break;
Larry Finger5e93f352014-03-28 21:37:38 -05001267
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +02001268 case WLAN_EID_TIM:
Jes Sorensenb54e8802014-04-09 23:20:52 +02001269 update_BCNTIM(padapter);
1270 break;
Larry Finger5e93f352014-03-28 21:37:38 -05001271
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +02001272 case WLAN_EID_ERP_INFO:
Jes Sorensenb54e8802014-04-09 23:20:52 +02001273 update_bcn_erpinfo_ie(padapter);
1274 break;
Larry Finger5e93f352014-03-28 21:37:38 -05001275
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +02001276 case WLAN_EID_HT_CAPABILITY:
Jes Sorensenb54e8802014-04-09 23:20:52 +02001277 update_bcn_htcap_ie(padapter);
1278 break;
Larry Finger5e93f352014-03-28 21:37:38 -05001279
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +02001280 case WLAN_EID_RSN:
Jes Sorensenb54e8802014-04-09 23:20:52 +02001281 update_bcn_rsn_ie(padapter);
1282 break;
Larry Finger5e93f352014-03-28 21:37:38 -05001283
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +02001284 case WLAN_EID_HT_OPERATION:
Jes Sorensenb54e8802014-04-09 23:20:52 +02001285 update_bcn_htinfo_ie(padapter);
1286 break;
Larry Finger5e93f352014-03-28 21:37:38 -05001287
Jes Sorensen9300c942014-04-15 19:43:21 +02001288 case WLAN_EID_VENDOR_SPECIFIC:
Jes Sorensenb54e8802014-04-09 23:20:52 +02001289 update_bcn_vendor_spec_ie(padapter, oui);
1290 break;
Larry Finger5e93f352014-03-28 21:37:38 -05001291
Jes Sorensenb54e8802014-04-09 23:20:52 +02001292 default:
1293 break;
Larry Finger5e93f352014-03-28 21:37:38 -05001294 }
1295
1296 pmlmepriv->update_bcn = true;
1297
1298 spin_unlock_bh(&pmlmepriv->bcn_update_lock);
1299
1300 if (tx)
1301 set_tx_beacon_cmd23a(padapter);
1302}
1303
1304/*
1305op_mode
Masanari Iida96b0a5b2014-07-22 23:42:45 +09001306Set to 0 (HT pure) under the following conditions
Larry Finger5e93f352014-03-28 21:37:38 -05001307 - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
1308 - all STAs in the BSS are 20 MHz HT in 20 MHz BSS
1309Set to 1 (HT non-member protection) if there may be non-HT STAs
1310 in both the primary and the secondary channel
1311Set to 2 if only HT STAs are associated in BSS,
1312 however and at least one 20 MHz HT STA is associated
1313Set to 3 (HT mixed mode) when one or more non-HT STAs are associated
1314 (currently non-GF HT station is considered as non-HT STA also)
1315*/
1316static int rtw_ht_operation_update(struct rtw_adapter *padapter)
1317{
1318 u16 cur_op_mode, new_op_mode;
1319 int op_mode_changes = 0;
1320 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1321 struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv;
1322
Jes Sorensen6a5f6572014-06-09 15:16:07 +02001323 if (pmlmepriv->htpriv.ht_option)
Larry Finger5e93f352014-03-28 21:37:38 -05001324 return 0;
1325
1326 /* if (!iface->conf->ieee80211n || iface->conf->ht_op_mode_fixed) */
1327 /* return 0; */
1328
1329 DBG_8723A("%s current operation mode = 0x%X\n",
1330 __func__, pmlmepriv->ht_op_mode);
1331
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001332 if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)
Larry Finger5e93f352014-03-28 21:37:38 -05001333 && pmlmepriv->num_sta_ht_no_gf) {
1334 pmlmepriv->ht_op_mode |=
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001335 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
Larry Finger5e93f352014-03-28 21:37:38 -05001336 op_mode_changes++;
1337 } else if ((pmlmepriv->ht_op_mode &
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001338 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) &&
Larry Finger5e93f352014-03-28 21:37:38 -05001339 pmlmepriv->num_sta_ht_no_gf == 0) {
1340 pmlmepriv->ht_op_mode &=
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001341 ~IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
Larry Finger5e93f352014-03-28 21:37:38 -05001342 op_mode_changes++;
1343 }
1344
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001345 if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) &&
Larry Finger5e93f352014-03-28 21:37:38 -05001346 (pmlmepriv->num_sta_no_ht || pmlmepriv->olbc_ht)) {
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001347 pmlmepriv->ht_op_mode |= IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
Larry Finger5e93f352014-03-28 21:37:38 -05001348 op_mode_changes++;
1349 } else if ((pmlmepriv->ht_op_mode &
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001350 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) &&
Larry Finger5e93f352014-03-28 21:37:38 -05001351 (pmlmepriv->num_sta_no_ht == 0 && !pmlmepriv->olbc_ht)) {
1352 pmlmepriv->ht_op_mode &=
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001353 ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
Larry Finger5e93f352014-03-28 21:37:38 -05001354 op_mode_changes++;
1355 }
1356
1357 /* Note: currently we switch to the MIXED op mode if HT non-greenfield
1358 * station is associated. Probably it's a theoretical case, since
1359 * it looks like all known HT STAs support greenfield.
1360 */
Larry Finger5e93f352014-03-28 21:37:38 -05001361 if (pmlmepriv->num_sta_no_ht ||
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001362 (pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT))
Jes Sorensenc3899282014-05-21 09:37:51 +02001363 new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
Larry Fingera96ae6f2014-04-26 18:55:18 +02001364 else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) &
1365 IEEE80211_HT_CAP_SUP_WIDTH_20_40) &&
1366 pmlmepriv->num_sta_ht_20mhz)
Jes Sorensenc3899282014-05-21 09:37:51 +02001367 new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
Larry Finger5e93f352014-03-28 21:37:38 -05001368 else if (pmlmepriv->olbc_ht)
Jes Sorensenc3899282014-05-21 09:37:51 +02001369 new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
Larry Finger5e93f352014-03-28 21:37:38 -05001370 else
Jes Sorensenc3899282014-05-21 09:37:51 +02001371 new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
Larry Finger5e93f352014-03-28 21:37:38 -05001372
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001373 cur_op_mode = pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_PROTECTION;
Larry Finger5e93f352014-03-28 21:37:38 -05001374 if (cur_op_mode != new_op_mode) {
Jes Sorensen2c50c7c2014-05-21 09:37:47 +02001375 pmlmepriv->ht_op_mode &= ~IEEE80211_HT_OP_MODE_PROTECTION;
Larry Finger5e93f352014-03-28 21:37:38 -05001376 pmlmepriv->ht_op_mode |= new_op_mode;
1377 op_mode_changes++;
1378 }
1379
1380 DBG_8723A("%s new operation mode = 0x%X changes =%d\n",
1381 __func__, pmlmepriv->ht_op_mode, op_mode_changes);
1382
1383 return op_mode_changes;
1384}
1385
1386void associated_clients_update23a(struct rtw_adapter *padapter, u8 updated)
1387{
Masanari Iida96b0a5b2014-07-22 23:42:45 +09001388 /* update associated stations cap. */
Larry Finger5e93f352014-03-28 21:37:38 -05001389 if (updated == true)
1390 {
1391 struct list_head *phead, *plist, *ptmp;
1392 struct sta_info *psta;
1393 struct sta_priv *pstapriv = &padapter->stapriv;
1394
1395 spin_lock_bh(&pstapriv->asoc_list_lock);
1396
1397 phead = &pstapriv->asoc_list;
1398
1399 list_for_each_safe(plist, ptmp, phead) {
1400 psta = container_of(plist, struct sta_info, asoc_list);
1401
1402 VCS_update23a(padapter, psta);
1403 }
1404
1405 spin_unlock_bh(&pstapriv->asoc_list_lock);
1406 }
1407}
1408
1409/* called > TSR LEVEL for USB or SDIO Interface*/
1410void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info *psta)
1411{
1412 u8 beacon_updated = false;
1413 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1414 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1415
1416 if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE))
1417 {
1418 if (!psta->no_short_preamble_set)
1419 {
1420 psta->no_short_preamble_set = 1;
1421
1422 pmlmepriv->num_sta_no_short_preamble++;
1423
1424 if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
1425 (pmlmepriv->num_sta_no_short_preamble == 1))
1426 {
1427 beacon_updated = true;
1428 update_beacon23a(padapter, 0xFF, NULL, true);
1429 }
1430
1431 }
1432 }
1433 else
1434 {
1435 if (psta->no_short_preamble_set)
1436 {
1437 psta->no_short_preamble_set = 0;
1438
1439 pmlmepriv->num_sta_no_short_preamble--;
1440
1441 if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
1442 (pmlmepriv->num_sta_no_short_preamble == 0))
1443 {
1444 beacon_updated = true;
1445 update_beacon23a(padapter, 0xFF, NULL, true);
1446 }
1447
1448 }
1449 }
1450
1451 if (psta->flags & WLAN_STA_NONERP)
1452 {
1453 if (!psta->nonerp_set)
1454 {
1455 psta->nonerp_set = 1;
1456
1457 pmlmepriv->num_sta_non_erp++;
1458
1459 if (pmlmepriv->num_sta_non_erp == 1)
1460 {
1461 beacon_updated = true;
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +02001462 update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true);
Larry Finger5e93f352014-03-28 21:37:38 -05001463 }
1464 }
1465
1466 }
1467 else
1468 {
1469 if (psta->nonerp_set)
1470 {
1471 psta->nonerp_set = 0;
1472
1473 pmlmepriv->num_sta_non_erp--;
1474
1475 if (pmlmepriv->num_sta_non_erp == 0)
1476 {
1477 beacon_updated = true;
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +02001478 update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true);
Larry Finger5e93f352014-03-28 21:37:38 -05001479 }
1480 }
1481
1482 }
1483
1484 if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME))
1485 {
1486 if (!psta->no_short_slot_time_set)
1487 {
1488 psta->no_short_slot_time_set = 1;
1489
1490 pmlmepriv->num_sta_no_short_slot_time++;
1491
1492 if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
1493 (pmlmepriv->num_sta_no_short_slot_time == 1))
1494 {
1495 beacon_updated = true;
1496 update_beacon23a(padapter, 0xFF, NULL, true);
1497 }
1498
1499 }
1500 }
1501 else
1502 {
1503 if (psta->no_short_slot_time_set)
1504 {
1505 psta->no_short_slot_time_set = 0;
1506
1507 pmlmepriv->num_sta_no_short_slot_time--;
1508
1509 if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) &&
1510 (pmlmepriv->num_sta_no_short_slot_time == 0))
1511 {
1512 beacon_updated = true;
1513 update_beacon23a(padapter, 0xFF, NULL, true);
1514 }
1515 }
1516 }
1517
1518 if (psta->flags & WLAN_STA_HT)
1519 {
1520 u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info);
1521
1522 DBG_8723A("HT: STA " MAC_FMT " HT Capabilities "
1523 "Info: 0x%04x\n", MAC_ARG(psta->hwaddr), ht_capab);
1524
1525 if (psta->no_ht_set) {
1526 psta->no_ht_set = 0;
1527 pmlmepriv->num_sta_no_ht--;
1528 }
1529
1530 if ((ht_capab & IEEE80211_HT_CAP_GRN_FLD) == 0) {
1531 if (!psta->no_ht_gf_set) {
1532 psta->no_ht_gf_set = 1;
1533 pmlmepriv->num_sta_ht_no_gf++;
1534 }
1535 DBG_8723A("%s STA " MAC_FMT " - no "
1536 "greenfield, num of non-gf stations %d\n",
1537 __func__, MAC_ARG(psta->hwaddr),
1538 pmlmepriv->num_sta_ht_no_gf);
1539 }
1540
1541 if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH_20_40) == 0) {
1542 if (!psta->ht_20mhz_set) {
1543 psta->ht_20mhz_set = 1;
1544 pmlmepriv->num_sta_ht_20mhz++;
1545 }
1546 DBG_8723A("%s STA " MAC_FMT " - 20 MHz HT, "
1547 "num of 20MHz HT STAs %d\n",
1548 __func__, MAC_ARG(psta->hwaddr),
1549 pmlmepriv->num_sta_ht_20mhz);
1550 }
1551
1552 }
1553 else
1554 {
1555 if (!psta->no_ht_set) {
1556 psta->no_ht_set = 1;
1557 pmlmepriv->num_sta_no_ht++;
1558 }
Jes Sorensen6a5f6572014-06-09 15:16:07 +02001559 if (pmlmepriv->htpriv.ht_option) {
Larry Finger5e93f352014-03-28 21:37:38 -05001560 DBG_8723A("%s STA " MAC_FMT
1561 " - no HT, num of non-HT stations %d\n",
1562 __func__, MAC_ARG(psta->hwaddr),
1563 pmlmepriv->num_sta_no_ht);
1564 }
1565 }
1566
1567 if (rtw_ht_operation_update(padapter) > 0)
1568 {
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +02001569 update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false);
1570 update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true);
Larry Finger5e93f352014-03-28 21:37:38 -05001571 }
1572
Masanari Iida96b0a5b2014-07-22 23:42:45 +09001573 /* update associated stations cap. */
Larry Finger5e93f352014-03-28 21:37:38 -05001574 associated_clients_update23a(padapter, beacon_updated);
1575
1576 DBG_8723A("%s, updated =%d\n", __func__, beacon_updated);
1577}
1578
1579u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info *psta)
1580{
1581 u8 beacon_updated = false;
1582 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1583 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1584
1585 if (!psta)
1586 return beacon_updated;
1587
1588 if (psta->no_short_preamble_set) {
1589 psta->no_short_preamble_set = 0;
1590 pmlmepriv->num_sta_no_short_preamble--;
1591 if (pmlmeext->cur_wireless_mode > WIRELESS_11B
1592 && pmlmepriv->num_sta_no_short_preamble == 0)
1593 {
1594 beacon_updated = true;
1595 update_beacon23a(padapter, 0xFF, NULL, true);
1596 }
1597 }
1598
1599 if (psta->nonerp_set) {
1600 psta->nonerp_set = 0;
1601 pmlmepriv->num_sta_non_erp--;
1602 if (pmlmepriv->num_sta_non_erp == 0)
1603 {
1604 beacon_updated = true;
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +02001605 update_beacon23a(padapter, WLAN_EID_ERP_INFO,
1606 NULL, true);
Larry Finger5e93f352014-03-28 21:37:38 -05001607 }
1608 }
1609
1610 if (psta->no_short_slot_time_set) {
1611 psta->no_short_slot_time_set = 0;
1612 pmlmepriv->num_sta_no_short_slot_time--;
1613 if (pmlmeext->cur_wireless_mode > WIRELESS_11B
1614 && pmlmepriv->num_sta_no_short_slot_time == 0)
1615 {
1616 beacon_updated = true;
1617 update_beacon23a(padapter, 0xFF, NULL, true);
1618 }
1619 }
1620
1621 if (psta->no_ht_gf_set) {
1622 psta->no_ht_gf_set = 0;
1623 pmlmepriv->num_sta_ht_no_gf--;
1624 }
1625
1626 if (psta->no_ht_set) {
1627 psta->no_ht_set = 0;
1628 pmlmepriv->num_sta_no_ht--;
1629 }
1630
1631 if (psta->ht_20mhz_set) {
1632 psta->ht_20mhz_set = 0;
1633 pmlmepriv->num_sta_ht_20mhz--;
1634 }
1635
1636 if (rtw_ht_operation_update(padapter) > 0)
1637 {
Jes Sorensenaf2cb2c2014-04-15 19:43:26 +02001638 update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false);
1639 update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true);
Larry Finger5e93f352014-03-28 21:37:38 -05001640 }
1641
Masanari Iida96b0a5b2014-07-22 23:42:45 +09001642 /* update associated stations cap. */
Larry Finger5e93f352014-03-28 21:37:38 -05001643
1644 DBG_8723A("%s, updated =%d\n", __func__, beacon_updated);
1645
1646 return beacon_updated;
1647}
1648
1649u8 ap_free_sta23a(struct rtw_adapter *padapter, struct sta_info *psta, bool active, u16 reason)
1650{
1651 struct sta_priv *pstapriv = &padapter->stapriv;
1652 u8 beacon_updated = false;
1653
1654 if (!psta)
1655 return beacon_updated;
1656
1657 if (active == true)
1658 {
1659 /* tear down Rx AMPDU */
1660 send_delba23a(padapter, 0, psta->hwaddr);/* recipient */
1661
1662 /* tear down TX AMPDU */
1663 send_delba23a(padapter, 1, psta->hwaddr);/* originator */
1664
1665 issue_deauth23a(padapter, psta->hwaddr, reason);
1666 }
1667
1668 psta->htpriv.agg_enable_bitmap = 0x0;/* reset */
1669 psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */
1670
1671 /* report_del_sta_event23a(padapter, psta->hwaddr, reason); */
1672
1673 /* clear cam entry / key */
1674 /* clear_cam_entry23a(padapter, (psta->mac_id + 3)); */
Greg Donald7e6646d2014-09-06 19:42:03 -05001675 rtw_clearstakey_cmd23a(padapter, (u8 *)psta, (u8)(psta->mac_id + 3),
1676 true);
Larry Finger5e93f352014-03-28 21:37:38 -05001677
1678 spin_lock_bh(&psta->lock);
1679 psta->state &= ~_FW_LINKED;
1680 spin_unlock_bh(&psta->lock);
1681
1682 rtw_cfg80211_indicate_sta_disassoc(padapter, psta->hwaddr, reason);
1683
1684 report_del_sta_event23a(padapter, psta->hwaddr, reason);
1685
1686 beacon_updated = bss_cap_update_on_sta_leave23a(padapter, psta);
1687
1688 spin_lock_bh(&pstapriv->sta_hash_lock);
1689 rtw_free_stainfo23a(padapter, psta);
1690 spin_unlock_bh(&pstapriv->sta_hash_lock);
1691
1692 return beacon_updated;
1693}
1694
1695int rtw_ap_inform_ch_switch23a (struct rtw_adapter *padapter, u8 new_ch, u8 ch_offset)
1696{
1697 struct list_head *phead, *plist;
Larry Finger5e93f352014-03-28 21:37:38 -05001698 struct sta_info *psta = NULL;
1699 struct sta_priv *pstapriv = &padapter->stapriv;
1700 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1701 struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
1702 u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1703
Jes Sorensen6ec26272014-07-17 22:59:46 +02001704 if ((pmlmeinfo->state&0x03) != MSR_AP)
Heena Sirwanif9800f82014-10-07 14:46:30 +05301705 return 0;
Larry Finger5e93f352014-03-28 21:37:38 -05001706
Jes Sorensena790d582014-05-09 15:04:04 +02001707 DBG_8723A("%s(%s): with ch:%u, offset:%u\n", __func__,
1708 padapter->pnetdev->name, new_ch, ch_offset);
Larry Finger5e93f352014-03-28 21:37:38 -05001709
1710 spin_lock_bh(&pstapriv->asoc_list_lock);
1711 phead = &pstapriv->asoc_list;
1712
1713 list_for_each(plist, phead) {
1714 psta = container_of(plist, struct sta_info, asoc_list);
1715
1716 issue_action_spct_ch_switch23a (padapter, psta->hwaddr, new_ch, ch_offset);
1717 psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : (pstapriv->expire_to * 2);
1718 }
1719 spin_unlock_bh(&pstapriv->asoc_list_lock);
1720
1721 issue_action_spct_ch_switch23a (padapter, bc_addr, new_ch, ch_offset);
1722
Heena Sirwanif9800f82014-10-07 14:46:30 +05301723 return 0;
Larry Finger5e93f352014-03-28 21:37:38 -05001724}
1725
1726int rtw_sta_flush23a(struct rtw_adapter *padapter)
1727{
1728 struct list_head *phead, *plist, *ptmp;
Larry Finger5e93f352014-03-28 21:37:38 -05001729 struct sta_info *psta;
1730 struct sta_priv *pstapriv = &padapter->stapriv;
1731 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1732 struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
1733 u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1734 u8 chk_alive_num = 0;
Jes Sorensen69642132014-05-09 15:03:47 +02001735 struct sta_info *chk_alive_list[NUM_STA];
Larry Finger5e93f352014-03-28 21:37:38 -05001736 int i;
1737
Jes Sorensena790d582014-05-09 15:04:04 +02001738 DBG_8723A("%s(%s)\n", __func__, padapter->pnetdev->name);
Larry Finger5e93f352014-03-28 21:37:38 -05001739
Jes Sorensen6ec26272014-07-17 22:59:46 +02001740 if ((pmlmeinfo->state&0x03) != MSR_AP)
Heena Sirwanif9800f82014-10-07 14:46:30 +05301741 return 0;
Larry Finger5e93f352014-03-28 21:37:38 -05001742
1743 spin_lock_bh(&pstapriv->asoc_list_lock);
1744 phead = &pstapriv->asoc_list;
1745
1746 list_for_each_safe(plist, ptmp, phead) {
Larry Finger5e93f352014-03-28 21:37:38 -05001747 psta = container_of(plist, struct sta_info, asoc_list);
1748
1749 /* Remove sta from asoc_list */
1750 list_del_init(&psta->asoc_list);
1751 pstapriv->asoc_list_cnt--;
1752
1753 /* Keep sta for ap_free_sta23a() beyond this asoc_list loop */
Jes Sorensen69642132014-05-09 15:03:47 +02001754 chk_alive_list[chk_alive_num++] = psta;
Larry Finger5e93f352014-03-28 21:37:38 -05001755 }
1756 spin_unlock_bh(&pstapriv->asoc_list_lock);
1757
1758 /* For each sta in chk_alive_list, call ap_free_sta23a */
Jes Sorensen69642132014-05-09 15:03:47 +02001759 for (i = 0; i < chk_alive_num; i++)
1760 ap_free_sta23a(padapter, chk_alive_list[i], true,
1761 WLAN_REASON_DEAUTH_LEAVING);
Larry Finger5e93f352014-03-28 21:37:38 -05001762
1763 issue_deauth23a(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING);
1764
1765 associated_clients_update23a(padapter, true);
1766
Heena Sirwanif9800f82014-10-07 14:46:30 +05301767 return 0;
Larry Finger5e93f352014-03-28 21:37:38 -05001768}
1769
1770/* called > TSR LEVEL for USB or SDIO Interface*/
1771void sta_info_update23a(struct rtw_adapter *padapter, struct sta_info *psta)
1772{
1773 int flags = psta->flags;
1774 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1775
1776 /* update wmm cap. */
1777 if (WLAN_STA_WME&flags)
1778 psta->qos_option = 1;
1779 else
1780 psta->qos_option = 0;
1781
Jes Sorensenbd8ad4a2014-05-09 15:03:21 +02001782 if (pmlmepriv->qos_option == 0)
Larry Finger5e93f352014-03-28 21:37:38 -05001783 psta->qos_option = 0;
1784
1785 /* update 802.11n ht cap. */
1786 if (WLAN_STA_HT&flags)
1787 {
1788 psta->htpriv.ht_option = true;
1789 psta->qos_option = 1;
1790 }
1791 else
1792 {
1793 psta->htpriv.ht_option = false;
1794 }
1795
Jes Sorensen6a5f6572014-06-09 15:16:07 +02001796 if (!pmlmepriv->htpriv.ht_option)
Larry Finger5e93f352014-03-28 21:37:38 -05001797 psta->htpriv.ht_option = false;
1798
1799 update_sta_info23a_apmode23a(padapter, psta);
1800}
1801
1802/* called >= TSR LEVEL for USB or SDIO Interface*/
1803void ap_sta_info_defer_update23a(struct rtw_adapter *padapter, struct sta_info *psta)
1804{
1805 if (psta->state & _FW_LINKED)
1806 {
1807 /* add ratid */
1808 add_RATid23a(padapter, psta, 0);/* DM_RATR_STA_INIT */
1809 }
1810}
1811
1812/* restore hw setting from sw data structures */
1813void rtw_ap_restore_network(struct rtw_adapter *padapter)
1814{
1815 struct mlme_priv *mlmepriv = &padapter->mlmepriv;
1816 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
Greg Donald8e3d1612014-10-02 18:28:41 -05001817 struct sta_priv *pstapriv = &padapter->stapriv;
Larry Finger5e93f352014-03-28 21:37:38 -05001818 struct sta_info *psta;
1819 struct security_priv *psecuritypriv = &padapter->securitypriv;
1820 struct list_head *phead, *plist, *ptmp;
1821 u8 chk_alive_num = 0;
Jes Sorensen69642132014-05-09 15:03:47 +02001822 struct sta_info *chk_alive_list[NUM_STA];
Larry Finger5e93f352014-03-28 21:37:38 -05001823 int i;
1824
Jes Sorensenefc71442014-05-21 09:37:26 +02001825 rtw_setopmode_cmd23a(padapter, NL80211_IFTYPE_AP);
Larry Finger5e93f352014-03-28 21:37:38 -05001826
1827 set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
1828
Greg Donald7e6646d2014-09-06 19:42:03 -05001829 start_bss_network(padapter, (u8 *)&mlmepriv->cur_network.network);
Larry Finger5e93f352014-03-28 21:37:38 -05001830
Jes Sorensen9e3d6df2014-05-21 09:37:34 +02001831 if (padapter->securitypriv.dot11PrivacyAlgrthm ==
1832 WLAN_CIPHER_SUITE_TKIP ||
1833 padapter->securitypriv.dot11PrivacyAlgrthm ==
1834 WLAN_CIPHER_SUITE_CCMP) {
Larry Finger5e93f352014-03-28 21:37:38 -05001835 /* restore group key, WEP keys is restored in ips_leave23a() */
Jes Sorensen9e3d6df2014-05-21 09:37:34 +02001836 rtw_set_key23a(padapter, psecuritypriv,
1837 psecuritypriv->dot118021XGrpKeyid, 0);
Larry Finger5e93f352014-03-28 21:37:38 -05001838 }
1839
1840 /* per sta pairwise key and settings */
Jes Sorensen9e3d6df2014-05-21 09:37:34 +02001841 if (padapter->securitypriv.dot11PrivacyAlgrthm !=
1842 WLAN_CIPHER_SUITE_TKIP &&
1843 padapter->securitypriv.dot11PrivacyAlgrthm !=
1844 WLAN_CIPHER_SUITE_CCMP) {
Larry Finger5e93f352014-03-28 21:37:38 -05001845 return;
1846 }
1847
1848 spin_lock_bh(&pstapriv->asoc_list_lock);
1849
1850 phead = &pstapriv->asoc_list;
1851
1852 list_for_each_safe(plist, ptmp, phead) {
Larry Finger5e93f352014-03-28 21:37:38 -05001853 psta = container_of(plist, struct sta_info, asoc_list);
1854
Jes Sorensen69642132014-05-09 15:03:47 +02001855 chk_alive_list[chk_alive_num++] = psta;
Larry Finger5e93f352014-03-28 21:37:38 -05001856 }
1857
1858 spin_unlock_bh(&pstapriv->asoc_list_lock);
1859
1860 for (i = 0; i < chk_alive_num; i++) {
Jes Sorensen69642132014-05-09 15:03:47 +02001861 psta = chk_alive_list[i];
Larry Finger5e93f352014-03-28 21:37:38 -05001862
MihaelaGamanadabff82014-09-14 12:56:43 +03001863 if (psta->state & _FW_LINKED) {
Larry Finger5e93f352014-03-28 21:37:38 -05001864 Update_RA_Entry23a(padapter, psta);
1865 /* pairwise key */
1866 rtw_setstakey_cmd23a(padapter, (unsigned char *)psta, true);
1867 }
1868 }
1869}
1870
1871void start_ap_mode23a(struct rtw_adapter *padapter)
1872{
1873 int i;
1874 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1875 struct sta_priv *pstapriv = &padapter->stapriv;
1876 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1877 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
1878
1879 pmlmepriv->update_bcn = false;
1880
1881 /* init_mlme_ap_info23a(padapter); */
1882 pmlmeext->bstart_bss = false;
1883
1884 pmlmepriv->num_sta_non_erp = 0;
1885
1886 pmlmepriv->num_sta_no_short_slot_time = 0;
1887
1888 pmlmepriv->num_sta_no_short_preamble = 0;
1889
1890 pmlmepriv->num_sta_ht_no_gf = 0;
1891 pmlmepriv->num_sta_no_ht = 0;
1892 pmlmepriv->num_sta_ht_20mhz = 0;
1893
1894 pmlmepriv->olbc = false;
1895
1896 pmlmepriv->olbc_ht = false;
1897
1898 pmlmepriv->ht_op_mode = 0;
1899
MihaelaGamanadabff82014-09-14 12:56:43 +03001900 for (i = 0; i < NUM_STA; i++)
Larry Finger5e93f352014-03-28 21:37:38 -05001901 pstapriv->sta_aid[i] = NULL;
1902
Larry Finger5e93f352014-03-28 21:37:38 -05001903 /* for ACL */
1904 INIT_LIST_HEAD(&pacl_list->acl_node_q.queue);
1905 pacl_list->num = 0;
1906 pacl_list->mode = 0;
1907 for (i = 0; i < NUM_ACL; i++) {
1908 INIT_LIST_HEAD(&pacl_list->aclnode[i].list);
1909 pacl_list->aclnode[i].valid = false;
1910 }
1911}
1912
1913void stop_ap_mode23a(struct rtw_adapter *padapter)
1914{
1915 struct list_head *phead, *plist, *ptmp;
1916 struct rtw_wlan_acl_node *paclnode;
1917 struct sta_info *psta = NULL;
1918 struct sta_priv *pstapriv = &padapter->stapriv;
1919 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
1920 struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
1921 struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
1922 struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q;
1923
1924 pmlmepriv->update_bcn = false;
1925 pmlmeext->bstart_bss = false;
1926
1927 /* reset and init security priv , this can refine with rtw_reset_securitypriv23a */
1928 memset((unsigned char *)&padapter->securitypriv, 0, sizeof (struct security_priv));
1929 padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
1930 padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
1931
1932 /* for ACL */
1933 spin_lock_bh(&pacl_node_q->lock);
1934 phead = get_list_head(pacl_node_q);
1935
1936 list_for_each_safe(plist, ptmp, phead) {
1937 paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
1938
1939 if (paclnode->valid == true) {
1940 paclnode->valid = false;
1941
1942 list_del_init(&paclnode->list);
1943
1944 pacl_list->num--;
1945 }
1946 }
1947 spin_unlock_bh(&pacl_node_q->lock);
1948
1949 DBG_8723A("%s, free acl_node_queue, num =%d\n", __func__, pacl_list->num);
1950
1951 rtw_sta_flush23a(padapter);
1952
1953 /* free_assoc_sta_resources */
1954 rtw_free_all_stainfo23a(padapter);
1955
1956 psta = rtw_get_bcmc_stainfo23a(padapter);
1957 spin_lock_bh(&pstapriv->sta_hash_lock);
1958 rtw_free_stainfo23a(padapter, psta);
1959 spin_unlock_bh(&pstapriv->sta_hash_lock);
1960
1961 rtw_init_bcmc_stainfo23a(padapter);
1962
1963 rtw23a_free_mlme_priv_ie_data(pmlmepriv);
1964}