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