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