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