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