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