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