1 /******************************************************************************
4 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5 * Linux device driver for RTL8192SU
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 * Modifications for inclusion into the Linux staging tree are
21 * Copyright(c) 2010 Larry Finger. All rights reserved.
23 * Contact information:
24 * WLAN FAE <wlanfae@realtek.com>
25 * Larry Finger <Larry.Finger@lwfinger.net>
27 ******************************************************************************/
29 #define _RTL871X_MLME_C_
31 #include "osdep_service.h"
32 #include "drv_types.h"
33 #include "recv_osdep.h"
34 #include "xmit_osdep.h"
35 #include "mlme_osdep.h"
38 #include "wlan_bssdef.h"
40 static void update_ht_cap(struct _adapter
*padapter
, u8
*pie
, uint ie_len
);
42 static sint
_init_mlme_priv(struct _adapter
*padapter
)
46 struct wlan_network
*pnetwork
;
47 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
49 memset((u8
*)pmlmepriv
, 0, sizeof(struct mlme_priv
));
50 pmlmepriv
->nic_hdl
= (u8
*)padapter
;
51 pmlmepriv
->pscanned
= NULL
;
52 pmlmepriv
->fw_state
= 0;
53 pmlmepriv
->cur_network
.network
.InfrastructureMode
=
54 Ndis802_11AutoUnknown
;
55 /* Maybe someday we should rename this variable to "active_mode"(Jeff)*/
56 pmlmepriv
->passive_mode
= 1; /* 1: active, 0: passive. */
57 spin_lock_init(&(pmlmepriv
->lock
));
58 spin_lock_init(&(pmlmepriv
->lock2
));
59 _init_queue(&(pmlmepriv
->free_bss_pool
));
60 _init_queue(&(pmlmepriv
->scanned_queue
));
61 set_scanned_network_val(pmlmepriv
, 0);
62 memset(&pmlmepriv
->assoc_ssid
, 0, sizeof(struct ndis_802_11_ssid
));
63 pbuf
= _malloc(MAX_BSS_CNT
* (sizeof(struct wlan_network
)));
66 pmlmepriv
->free_bss_buf
= pbuf
;
67 pnetwork
= (struct wlan_network
*)pbuf
;
68 for (i
= 0; i
< MAX_BSS_CNT
; i
++) {
69 _init_listhead(&(pnetwork
->list
));
70 list_insert_tail(&(pnetwork
->list
),
71 &(pmlmepriv
->free_bss_pool
.queue
));
74 pmlmepriv
->sitesurveyctrl
.last_rx_pkts
= 0;
75 pmlmepriv
->sitesurveyctrl
.last_tx_pkts
= 0;
76 pmlmepriv
->sitesurveyctrl
.traffic_busy
= false;
77 /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
78 r8712_init_mlme_timer(padapter
);
82 struct wlan_network
*_r8712_alloc_network(struct mlme_priv
*pmlmepriv
)
85 struct wlan_network
*pnetwork
;
86 struct __queue
*free_queue
= &pmlmepriv
->free_bss_pool
;
87 struct list_head
*plist
= NULL
;
89 if (_queue_empty(free_queue
) == true)
91 spin_lock_irqsave(&free_queue
->lock
, irqL
);
92 plist
= get_next(&(free_queue
->queue
));
93 pnetwork
= LIST_CONTAINOR(plist
, struct wlan_network
, list
);
94 list_delete(&pnetwork
->list
);
95 pnetwork
->last_scanned
= jiffies
;
96 pmlmepriv
->num_of_scanned
++;
97 spin_unlock_irqrestore(&free_queue
->lock
, irqL
);
101 static void _free_network(struct mlme_priv
*pmlmepriv
,
102 struct wlan_network
*pnetwork
)
104 u32 curr_time
, delta_time
;
106 struct __queue
*free_queue
= &(pmlmepriv
->free_bss_pool
);
108 if (pnetwork
== NULL
)
110 if (pnetwork
->fixed
== true)
113 delta_time
= (curr_time
- (u32
)pnetwork
->last_scanned
) / HZ
;
114 if (delta_time
< SCANQUEUE_LIFETIME
)
116 spin_lock_irqsave(&free_queue
->lock
, irqL
);
117 list_delete(&pnetwork
->list
);
118 list_insert_tail(&pnetwork
->list
, &free_queue
->queue
);
119 pmlmepriv
->num_of_scanned
--;
120 spin_unlock_irqrestore(&free_queue
->lock
, irqL
);
123 static void _free_network_nolock(struct mlme_priv
*pmlmepriv
,
124 struct wlan_network
*pnetwork
)
126 struct __queue
*free_queue
= &pmlmepriv
->free_bss_pool
;
128 if (pnetwork
== NULL
)
130 if (pnetwork
->fixed
== true)
132 list_delete(&pnetwork
->list
);
133 list_insert_tail(&pnetwork
->list
, get_list_head(free_queue
));
134 pmlmepriv
->num_of_scanned
--;
139 return the wlan_network with the matching addr
140 Shall be calle under atomic context...
141 to avoid possible racing condition...
143 static struct wlan_network
*_r8712_find_network(struct __queue
*scanned_queue
,
147 struct list_head
*phead
, *plist
;
148 struct wlan_network
*pnetwork
= NULL
;
149 u8 zero_addr
[ETH_ALEN
] = {0, 0, 0, 0, 0, 0};
151 if (!memcmp(zero_addr
, addr
, ETH_ALEN
))
153 spin_lock_irqsave(&scanned_queue
->lock
, irqL
);
154 phead
= get_list_head(scanned_queue
);
155 plist
= get_next(phead
);
156 while (plist
!= phead
) {
157 pnetwork
= LIST_CONTAINOR(plist
, struct wlan_network
, list
);
158 plist
= get_next(plist
);
159 if (!memcmp(addr
, pnetwork
->network
.MacAddress
, ETH_ALEN
))
162 spin_unlock_irqrestore(&scanned_queue
->lock
, irqL
);
166 static void _free_network_queue(struct _adapter
*padapter
)
169 struct list_head
*phead
, *plist
;
170 struct wlan_network
*pnetwork
;
171 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
172 struct __queue
*scanned_queue
= &pmlmepriv
->scanned_queue
;
174 spin_lock_irqsave(&scanned_queue
->lock
, irqL
);
175 phead
= get_list_head(scanned_queue
);
176 plist
= get_next(phead
);
177 while (end_of_queue_search(phead
, plist
) == false) {
178 pnetwork
= LIST_CONTAINOR(plist
, struct wlan_network
, list
);
179 plist
= get_next(plist
);
180 _free_network(pmlmepriv
, pnetwork
);
182 spin_unlock_irqrestore(&scanned_queue
->lock
, irqL
);
185 sint
r8712_if_up(struct _adapter
*padapter
)
189 if (padapter
->bDriverStopped
|| padapter
->bSurpriseRemoved
||
190 (check_fwstate(&padapter
->mlmepriv
, _FW_LINKED
) == false)) {
197 void r8712_generate_random_ibss(u8
*pibss
)
199 u32 curtime
= jiffies
;
201 pibss
[0] = 0x02; /*in ad-hoc mode bit1 must set to 1 */
204 pibss
[3] = (u8
)(curtime
& 0xff);
205 pibss
[4] = (u8
)((curtime
>>8) & 0xff);
206 pibss
[5] = (u8
)((curtime
>>16) & 0xff);
209 uint
r8712_get_ndis_wlan_bssid_ex_sz(struct ndis_wlan_bssid_ex
*bss
)
213 t_len
= sizeof(u32
) + 6 * sizeof(unsigned long) + 2 +
214 sizeof(struct ndis_802_11_ssid
) + sizeof(u32
) +
216 sizeof(enum NDIS_802_11_NETWORK_TYPE
) +
217 sizeof(struct NDIS_802_11_CONFIGURATION
) +
218 sizeof(enum NDIS_802_11_NETWORK_INFRASTRUCTURE
) +
219 sizeof(NDIS_802_11_RATES_EX
) +
220 sizeof(u32
) + bss
->IELength
;
224 u8
*r8712_get_capability_from_ie(u8
*ie
)
229 int r8712_init_mlme_priv(struct _adapter
*padapter
)
231 return _init_mlme_priv(padapter
);
234 void r8712_free_mlme_priv(struct mlme_priv
*pmlmepriv
)
236 kfree(pmlmepriv
->free_bss_buf
);
239 static struct wlan_network
*alloc_network(struct mlme_priv
*pmlmepriv
)
241 return _r8712_alloc_network(pmlmepriv
);
244 static void free_network_nolock(struct mlme_priv
*pmlmepriv
,
245 struct wlan_network
*pnetwork
)
247 _free_network_nolock(pmlmepriv
, pnetwork
);
250 void r8712_free_network_queue(struct _adapter
*dev
)
252 _free_network_queue(dev
);
256 return the wlan_network with the matching addr
258 Shall be calle under atomic context...
259 to avoid possible racing condition...
261 static struct wlan_network
*r8712_find_network(struct __queue
*scanned_queue
,
264 struct wlan_network
*pnetwork
= _r8712_find_network(scanned_queue
,
270 int r8712_is_same_ibss(struct _adapter
*adapter
, struct wlan_network
*pnetwork
)
273 struct security_priv
*psecuritypriv
= &adapter
->securitypriv
;
275 if ((psecuritypriv
->PrivacyAlgrthm
!= _NO_PRIVACY_
) &&
276 (pnetwork
->network
.Privacy
== 0))
278 else if ((psecuritypriv
->PrivacyAlgrthm
== _NO_PRIVACY_
) &&
279 (pnetwork
->network
.Privacy
== 1))
287 static int is_same_network(struct ndis_wlan_bssid_ex
*src
,
288 struct ndis_wlan_bssid_ex
*dst
)
292 memcpy((u8
*)&s_cap
, r8712_get_capability_from_ie(src
->IEs
), 2);
293 memcpy((u8
*)&d_cap
, r8712_get_capability_from_ie(dst
->IEs
), 2);
294 return (src
->Ssid
.SsidLength
== dst
->Ssid
.SsidLength
) &&
295 (src
->Configuration
.DSConfig
==
296 dst
->Configuration
.DSConfig
) &&
297 ((!memcmp(src
->MacAddress
, dst
->MacAddress
,
299 ((!memcmp(src
->Ssid
.Ssid
,
301 src
->Ssid
.SsidLength
))) &&
302 ((s_cap
& WLAN_CAPABILITY_IBSS
) ==
303 (d_cap
& WLAN_CAPABILITY_IBSS
)) &&
304 ((s_cap
& WLAN_CAPABILITY_BSS
) ==
305 (d_cap
& WLAN_CAPABILITY_BSS
));
309 struct wlan_network
*r8712_get_oldest_wlan_network(
310 struct __queue
*scanned_queue
)
312 struct list_head
*plist
, *phead
;
313 struct wlan_network
*pwlan
= NULL
;
314 struct wlan_network
*oldest
= NULL
;
316 phead
= get_list_head(scanned_queue
);
317 plist
= get_next(phead
);
319 if (end_of_queue_search(phead
, plist
) == true)
321 pwlan
= LIST_CONTAINOR(plist
, struct wlan_network
, list
);
322 if (pwlan
->fixed
!= true) {
323 if (oldest
== NULL
||
324 time_after((unsigned long)oldest
->last_scanned
,
325 (unsigned long)pwlan
->last_scanned
))
328 plist
= get_next(plist
);
333 static void update_network(struct ndis_wlan_bssid_ex
*dst
,
334 struct ndis_wlan_bssid_ex
*src
,
335 struct _adapter
*padapter
)
337 u32 last_evm
= 0, tmpVal
;
339 if (check_fwstate(&padapter
->mlmepriv
, _FW_LINKED
) &&
340 is_same_network(&(padapter
->mlmepriv
.cur_network
.network
), src
)) {
341 if (padapter
->recvpriv
.signal_qual_data
.total_num
++ >=
342 PHY_LINKQUALITY_SLID_WIN_MAX
) {
343 padapter
->recvpriv
.signal_qual_data
.total_num
=
344 PHY_LINKQUALITY_SLID_WIN_MAX
;
345 last_evm
= padapter
->recvpriv
.signal_qual_data
.
346 elements
[padapter
->recvpriv
.
347 signal_qual_data
.index
];
348 padapter
->recvpriv
.signal_qual_data
.total_val
-=
351 padapter
->recvpriv
.signal_qual_data
.total_val
+= src
->Rssi
;
353 padapter
->recvpriv
.signal_qual_data
.
354 elements
[padapter
->recvpriv
.signal_qual_data
.
355 index
++] = src
->Rssi
;
356 if (padapter
->recvpriv
.signal_qual_data
.index
>=
357 PHY_LINKQUALITY_SLID_WIN_MAX
)
358 padapter
->recvpriv
.signal_qual_data
.index
= 0;
359 /* <1> Showed on UI for user, in percentage. */
360 tmpVal
= padapter
->recvpriv
.signal_qual_data
.total_val
/
361 padapter
->recvpriv
.signal_qual_data
.total_num
;
362 padapter
->recvpriv
.signal
= (u8
)tmpVal
;
364 src
->Rssi
= padapter
->recvpriv
.signal
;
366 src
->Rssi
= (src
->Rssi
+ dst
->Rssi
) / 2;
367 memcpy((u8
*)dst
, (u8
*)src
, r8712_get_ndis_wlan_bssid_ex_sz(src
));
370 static void update_current_network(struct _adapter
*adapter
,
371 struct ndis_wlan_bssid_ex
*pnetwork
)
373 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
375 if (is_same_network(&(pmlmepriv
->cur_network
.network
), pnetwork
)) {
376 update_network(&(pmlmepriv
->cur_network
.network
),
378 r8712_update_protection(adapter
,
379 (pmlmepriv
->cur_network
.network
.IEs
) +
380 sizeof(struct NDIS_802_11_FIXED_IEs
),
381 pmlmepriv
->cur_network
.network
.IELength
);
386 Caller must hold pmlmepriv->lock first.
388 static void update_scanned_network(struct _adapter
*adapter
,
389 struct ndis_wlan_bssid_ex
*target
)
391 struct list_head
*plist
, *phead
;
394 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
395 struct __queue
*queue
= &pmlmepriv
->scanned_queue
;
396 struct wlan_network
*pnetwork
= NULL
;
397 struct wlan_network
*oldest
= NULL
;
399 phead
= get_list_head(queue
);
400 plist
= get_next(phead
);
403 if (end_of_queue_search(phead
, plist
) == true)
406 pnetwork
= LIST_CONTAINOR(plist
, struct wlan_network
, list
);
407 if (is_same_network(&pnetwork
->network
, target
))
409 if ((oldest
== ((struct wlan_network
*)0)) ||
410 time_after((unsigned long)oldest
->last_scanned
,
411 (unsigned long)pnetwork
->last_scanned
))
414 plist
= get_next(plist
);
418 /* If we didn't find a match, then get a new network slot to initialize
419 * with this beacon's information */
420 if (end_of_queue_search(phead
, plist
) == true) {
421 if (_queue_empty(&pmlmepriv
->free_bss_pool
) == true) {
422 /* If there are no more slots, expire the oldest */
424 target
->Rssi
= (pnetwork
->network
.Rssi
+
426 memcpy(&pnetwork
->network
, target
,
427 r8712_get_ndis_wlan_bssid_ex_sz(target
));
428 pnetwork
->last_scanned
= jiffies
;
430 /* Otherwise just pull from the free list */
431 /* update scan_time */
432 pnetwork
= alloc_network(pmlmepriv
);
433 if (pnetwork
== NULL
)
435 bssid_ex_sz
= r8712_get_ndis_wlan_bssid_ex_sz(target
);
436 target
->Length
= bssid_ex_sz
;
437 memcpy(&pnetwork
->network
, target
, bssid_ex_sz
);
438 list_insert_tail(&pnetwork
->list
, &queue
->queue
);
441 /* we have an entry and we are going to update it. But
442 * this entry may be already expired. In this case we
443 * do the same as we found a new net and call the new_net
446 update_network(&pnetwork
->network
, target
, adapter
);
447 pnetwork
->last_scanned
= jiffies
;
451 static void rtl8711_add_network(struct _adapter
*adapter
,
452 struct ndis_wlan_bssid_ex
*pnetwork
)
455 struct mlme_priv
*pmlmepriv
= &(((struct _adapter
*)adapter
)->mlmepriv
);
456 struct __queue
*queue
= &pmlmepriv
->scanned_queue
;
458 spin_lock_irqsave(&queue
->lock
, irqL
);
459 update_current_network(adapter
, pnetwork
);
460 update_scanned_network(adapter
, pnetwork
);
461 spin_unlock_irqrestore(&queue
->lock
, irqL
);
464 /*select the desired network based on the capability of the (i)bss.
465 * check items: (1) security
471 static int is_desired_network(struct _adapter
*adapter
,
472 struct wlan_network
*pnetwork
)
476 int bselected
= true;
477 struct security_priv
*psecuritypriv
= &adapter
->securitypriv
;
479 if (psecuritypriv
->wps_phase
== true) {
480 if (r8712_get_wps_ie(pnetwork
->network
.IEs
,
481 pnetwork
->network
.IELength
, wps_ie
,
487 if ((psecuritypriv
->PrivacyAlgrthm
!= _NO_PRIVACY_
) &&
488 (pnetwork
->network
.Privacy
== 0))
490 if (check_fwstate(&adapter
->mlmepriv
, WIFI_ADHOC_STATE
) == true) {
491 if (pnetwork
->network
.InfrastructureMode
!=
492 adapter
->mlmepriv
.cur_network
.network
.
499 /* TODO: Perry : For Power Management */
500 void r8712_atimdone_event_callback(struct _adapter
*adapter
, u8
*pbuf
)
504 void r8712_survey_event_callback(struct _adapter
*adapter
, u8
*pbuf
)
508 struct ndis_wlan_bssid_ex
*pnetwork
;
509 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
511 pnetwork
= (struct ndis_wlan_bssid_ex
*)pbuf
;
514 pnetwork
->Length
= le32_to_cpu(pnetwork
->Length
);
515 pnetwork
->Ssid
.SsidLength
= le32_to_cpu(pnetwork
->Ssid
.SsidLength
);
516 pnetwork
->Privacy
= le32_to_cpu(pnetwork
->Privacy
);
517 pnetwork
->Rssi
= le32_to_cpu(pnetwork
->Rssi
);
518 pnetwork
->NetworkTypeInUse
= le32_to_cpu(pnetwork
->NetworkTypeInUse
);
519 pnetwork
->Configuration
.ATIMWindow
=
520 le32_to_cpu(pnetwork
->Configuration
.ATIMWindow
);
521 pnetwork
->Configuration
.BeaconPeriod
=
522 le32_to_cpu(pnetwork
->Configuration
.BeaconPeriod
);
523 pnetwork
->Configuration
.DSConfig
=
524 le32_to_cpu(pnetwork
->Configuration
.DSConfig
);
525 pnetwork
->Configuration
.FHConfig
.DwellTime
=
526 le32_to_cpu(pnetwork
->Configuration
.FHConfig
.DwellTime
);
527 pnetwork
->Configuration
.FHConfig
.HopPattern
=
528 le32_to_cpu(pnetwork
->Configuration
.FHConfig
.HopPattern
);
529 pnetwork
->Configuration
.FHConfig
.HopSet
=
530 le32_to_cpu(pnetwork
->Configuration
.FHConfig
.HopSet
);
531 pnetwork
->Configuration
.FHConfig
.Length
=
532 le32_to_cpu(pnetwork
->Configuration
.FHConfig
.Length
);
533 pnetwork
->Configuration
.Length
=
534 le32_to_cpu(pnetwork
->Configuration
.Length
);
535 pnetwork
->InfrastructureMode
=
536 le32_to_cpu(pnetwork
->InfrastructureMode
);
537 pnetwork
->IELength
= le32_to_cpu(pnetwork
->IELength
);
539 len
= r8712_get_ndis_wlan_bssid_ex_sz(pnetwork
);
540 if (len
> sizeof(struct wlan_bssid_ex
))
542 spin_lock_irqsave(&pmlmepriv
->lock2
, flags
);
543 /* update IBSS_network 's timestamp */
544 if (check_fwstate(pmlmepriv
, WIFI_ADHOC_MASTER_STATE
) == true) {
545 if (!memcmp(&(pmlmepriv
->cur_network
.network
.MacAddress
),
546 pnetwork
->MacAddress
, ETH_ALEN
)) {
547 struct wlan_network
*ibss_wlan
= NULL
;
549 memcpy(pmlmepriv
->cur_network
.network
.IEs
,
551 ibss_wlan
= r8712_find_network(
552 &pmlmepriv
->scanned_queue
,
553 pnetwork
->MacAddress
);
555 memcpy(ibss_wlan
->network
.IEs
,
561 /* lock pmlmepriv->lock when you accessing network_q */
562 if (check_fwstate(pmlmepriv
, _FW_UNDER_LINKING
) == false) {
563 if (pnetwork
->Ssid
.Ssid
[0] != 0)
564 rtl8711_add_network(adapter
, pnetwork
);
566 pnetwork
->Ssid
.SsidLength
= 8;
567 memcpy(pnetwork
->Ssid
.Ssid
, "<hidden>", 8);
568 rtl8711_add_network(adapter
, pnetwork
);
572 spin_unlock_irqrestore(&pmlmepriv
->lock2
, flags
);
575 void r8712_surveydone_event_callback(struct _adapter
*adapter
, u8
*pbuf
)
578 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
580 spin_lock_irqsave(&pmlmepriv
->lock
, irqL
);
582 if (check_fwstate(pmlmepriv
, _FW_UNDER_SURVEY
) == true) {
585 _cancel_timer(&pmlmepriv
->scan_to_timer
, &timer_cancelled
);
587 _clr_fwstate_(pmlmepriv
, _FW_UNDER_SURVEY
);
590 if (pmlmepriv
->to_join
== true) {
591 if ((check_fwstate(pmlmepriv
, WIFI_ADHOC_STATE
) == true)) {
592 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == false) {
593 set_fwstate(pmlmepriv
, _FW_UNDER_LINKING
);
595 if (r8712_select_and_join_from_scan(pmlmepriv
)
597 _set_timer(&pmlmepriv
->assoc_timer
,
600 struct wlan_bssid_ex
*pdev_network
=
601 &(adapter
->registrypriv
.dev_network
);
603 adapter
->registrypriv
.
604 dev_network
.MacAddress
;
605 pmlmepriv
->fw_state
^= _FW_UNDER_SURVEY
;
606 memset(&pdev_network
->Ssid
, 0,
609 memcpy(&pdev_network
->Ssid
,
610 &pmlmepriv
->assoc_ssid
,
613 r8712_update_registrypriv_dev_network
615 r8712_generate_random_ibss(pibss
);
616 pmlmepriv
->fw_state
=
617 WIFI_ADHOC_MASTER_STATE
;
618 pmlmepriv
->to_join
= false;
622 pmlmepriv
->to_join
= false;
623 set_fwstate(pmlmepriv
, _FW_UNDER_LINKING
);
624 if (r8712_select_and_join_from_scan(pmlmepriv
) ==
626 _set_timer(&pmlmepriv
->assoc_timer
,
629 _clr_fwstate_(pmlmepriv
, _FW_UNDER_LINKING
);
632 spin_unlock_irqrestore(&pmlmepriv
->lock
, irqL
);
636 *r8712_free_assoc_resources: the caller has to lock pmlmepriv->lock
638 void r8712_free_assoc_resources(struct _adapter
*adapter
)
641 struct wlan_network
*pwlan
= NULL
;
642 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
643 struct sta_priv
*pstapriv
= &adapter
->stapriv
;
644 struct wlan_network
*tgt_network
= &pmlmepriv
->cur_network
;
646 pwlan
= r8712_find_network(&pmlmepriv
->scanned_queue
,
647 tgt_network
->network
.MacAddress
);
649 if (check_fwstate(pmlmepriv
, WIFI_STATION_STATE
|WIFI_AP_STATE
)) {
650 struct sta_info
*psta
;
652 psta
= r8712_get_stainfo(&adapter
->stapriv
,
653 tgt_network
->network
.MacAddress
);
655 spin_lock_irqsave(&pstapriv
->sta_hash_lock
, irqL
);
656 r8712_free_stainfo(adapter
, psta
);
657 spin_unlock_irqrestore(&pstapriv
->sta_hash_lock
, irqL
);
660 if (check_fwstate(pmlmepriv
,
661 WIFI_ADHOC_STATE
|WIFI_ADHOC_MASTER_STATE
|WIFI_AP_STATE
))
662 r8712_free_all_stainfo(adapter
);
664 pwlan
->fixed
= false;
666 if (((check_fwstate(pmlmepriv
, WIFI_ADHOC_MASTER_STATE
)) &&
667 (adapter
->stapriv
.asoc_sta_count
== 1)))
668 free_network_nolock(pmlmepriv
, pwlan
);
672 *r8712_indicate_connect: the caller has to lock pmlmepriv->lock
674 void r8712_indicate_connect(struct _adapter
*padapter
)
676 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
678 pmlmepriv
->to_join
= false;
679 set_fwstate(pmlmepriv
, _FW_LINKED
);
680 padapter
->ledpriv
.LedControlHandler(padapter
, LED_CTL_LINK
);
681 r8712_os_indicate_connect(padapter
);
682 if (padapter
->registrypriv
.power_mgnt
> PS_MODE_ACTIVE
)
683 _set_timer(&pmlmepriv
->dhcp_timer
, 60000);
688 *r8712_ind_disconnect: the caller has to lock pmlmepriv->lock
690 void r8712_ind_disconnect(struct _adapter
*padapter
)
692 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
694 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
695 _clr_fwstate_(pmlmepriv
, _FW_LINKED
);
696 padapter
->ledpriv
.LedControlHandler(padapter
, LED_CTL_NO_LINK
);
697 r8712_os_indicate_disconnect(padapter
);
699 if (padapter
->pwrctrlpriv
.pwr_mode
!=
700 padapter
->registrypriv
.power_mgnt
) {
701 _cancel_timer_ex(&pmlmepriv
->dhcp_timer
);
702 r8712_set_ps_mode(padapter
, padapter
->registrypriv
.power_mgnt
,
703 padapter
->registrypriv
.smart_ps
);
708 *pnetwork : returns from r8712_joinbss_event_callback
709 *ptarget_wlan: found from scanned_queue
710 *if join_res > 0, for (fw_state==WIFI_STATION_STATE), we check if
711 * "ptarget_sta" & "ptarget_wlan" exist.
712 *if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), we only check
713 * if "ptarget_wlan" exist.
714 *if join_res > 0, update "cur_network->network" from
715 * "pnetwork->network" if (ptarget_wlan !=NULL).
717 void r8712_joinbss_event_callback(struct _adapter
*adapter
, u8
*pbuf
)
719 unsigned long irqL
= 0, irqL2
;
721 struct sta_info
*ptarget_sta
= NULL
, *pcur_sta
= NULL
;
722 struct sta_priv
*pstapriv
= &adapter
->stapriv
;
723 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
724 struct wlan_network
*cur_network
= &pmlmepriv
->cur_network
;
725 struct wlan_network
*pcur_wlan
= NULL
, *ptarget_wlan
= NULL
;
726 unsigned int the_same_macaddr
= false;
727 struct wlan_network
*pnetwork
;
729 if (sizeof(struct list_head
) == 4 * sizeof(u32
)) {
730 pnetwork
= (struct wlan_network
*)
731 _malloc(sizeof(struct wlan_network
));
732 memcpy((u8
*)pnetwork
+16, (u8
*)pbuf
+ 8,
733 sizeof(struct wlan_network
) - 16);
735 pnetwork
= (struct wlan_network
*)pbuf
;
739 pnetwork
->join_res
= le32_to_cpu(pnetwork
->join_res
);
740 pnetwork
->network_type
= le32_to_cpu(pnetwork
->network_type
);
741 pnetwork
->network
.Length
= le32_to_cpu(pnetwork
->network
.Length
);
742 pnetwork
->network
.Ssid
.SsidLength
=
743 le32_to_cpu(pnetwork
->network
.Ssid
.SsidLength
);
744 pnetwork
->network
.Privacy
= le32_to_cpu(pnetwork
->network
.Privacy
);
745 pnetwork
->network
.Rssi
= le32_to_cpu(pnetwork
->network
.Rssi
);
746 pnetwork
->network
.NetworkTypeInUse
=
747 le32_to_cpu(pnetwork
->network
.NetworkTypeInUse
);
748 pnetwork
->network
.Configuration
.ATIMWindow
=
749 le32_to_cpu(pnetwork
->network
.Configuration
.ATIMWindow
);
750 pnetwork
->network
.Configuration
.BeaconPeriod
=
751 le32_to_cpu(pnetwork
->network
.Configuration
.BeaconPeriod
);
752 pnetwork
->network
.Configuration
.DSConfig
=
753 le32_to_cpu(pnetwork
->network
.Configuration
.DSConfig
);
754 pnetwork
->network
.Configuration
.FHConfig
.DwellTime
=
755 le32_to_cpu(pnetwork
->network
.Configuration
.FHConfig
.
757 pnetwork
->network
.Configuration
.FHConfig
.HopPattern
=
758 le32_to_cpu(pnetwork
->network
.Configuration
.
759 FHConfig
.HopPattern
);
760 pnetwork
->network
.Configuration
.FHConfig
.HopSet
=
761 le32_to_cpu(pnetwork
->network
.Configuration
.FHConfig
.HopSet
);
762 pnetwork
->network
.Configuration
.FHConfig
.Length
=
763 le32_to_cpu(pnetwork
->network
.Configuration
.FHConfig
.Length
);
764 pnetwork
->network
.Configuration
.Length
=
765 le32_to_cpu(pnetwork
->network
.Configuration
.Length
);
766 pnetwork
->network
.InfrastructureMode
=
767 le32_to_cpu(pnetwork
->network
.InfrastructureMode
);
768 pnetwork
->network
.IELength
= le32_to_cpu(pnetwork
->network
.IELength
);
771 the_same_macaddr
= !memcmp(pnetwork
->network
.MacAddress
,
772 cur_network
->network
.MacAddress
, ETH_ALEN
);
773 pnetwork
->network
.Length
=
774 r8712_get_ndis_wlan_bssid_ex_sz(&pnetwork
->network
);
775 spin_lock_irqsave(&pmlmepriv
->lock
, irqL
);
776 if (pnetwork
->network
.Length
> sizeof(struct wlan_bssid_ex
))
777 goto ignore_joinbss_callback
;
778 if (pnetwork
->join_res
> 0) {
779 if (check_fwstate(pmlmepriv
, _FW_UNDER_LINKING
) == true) {
780 /*s1. find ptarget_wlan*/
781 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
782 if (the_same_macaddr
== true)
784 r8712_find_network(&pmlmepriv
->
786 cur_network
->network
.MacAddress
);
789 r8712_find_network(&pmlmepriv
->
791 cur_network
->network
.MacAddress
);
792 pcur_wlan
->fixed
= false;
794 pcur_sta
= r8712_get_stainfo(pstapriv
,
795 cur_network
->network
.MacAddress
);
796 spin_lock_irqsave(&pstapriv
->
797 sta_hash_lock
, irqL2
);
798 r8712_free_stainfo(adapter
, pcur_sta
);
799 spin_unlock_irqrestore(&(pstapriv
->
800 sta_hash_lock
), irqL2
);
803 r8712_find_network(&pmlmepriv
->
808 ptarget_wlan
->fixed
= true;
811 ptarget_wlan
= r8712_find_network(&pmlmepriv
->
813 pnetwork
->network
.MacAddress
);
815 ptarget_wlan
->fixed
= true;
818 if (ptarget_wlan
== NULL
) {
819 if (check_fwstate(pmlmepriv
,
821 pmlmepriv
->fw_state
^=
823 goto ignore_joinbss_callback
;
826 /*s2. find ptarget_sta & update ptarget_sta*/
827 if (check_fwstate(pmlmepriv
, WIFI_STATION_STATE
)) {
828 if (the_same_macaddr
== true) {
830 r8712_get_stainfo(pstapriv
,
831 pnetwork
->network
.MacAddress
);
832 if (ptarget_sta
== NULL
)
834 r8712_alloc_stainfo(pstapriv
,
835 pnetwork
->network
.MacAddress
);
838 r8712_alloc_stainfo(pstapriv
,
839 pnetwork
->network
.MacAddress
);
840 if (ptarget_sta
) /*update ptarget_sta*/ {
841 ptarget_sta
->aid
= pnetwork
->join_res
;
842 ptarget_sta
->qos_option
= 1;
843 ptarget_sta
->mac_id
= 5;
844 if (adapter
->securitypriv
.
846 adapter
->securitypriv
.
849 adapter
->securitypriv
.
852 adapter
->securitypriv
.
855 ptarget_sta
->ieee8021x_blocked
857 ptarget_sta
->XPrivacy
=
858 adapter
->securitypriv
.
860 memset((u8
*)&ptarget_sta
->
863 sizeof(union Keytype
));
864 memset((u8
*)&ptarget_sta
->
867 sizeof(union Keytype
));
868 memset((u8
*)&ptarget_sta
->
871 sizeof(union Keytype
));
872 memset((u8
*)&ptarget_sta
->
875 memset((u8
*)&ptarget_sta
->
880 if (check_fwstate(pmlmepriv
,
882 pmlmepriv
->fw_state
^=
884 goto ignore_joinbss_callback
;
888 /*s3. update cur_network & indicate connect*/
889 memcpy(&cur_network
->network
, &pnetwork
->network
,
890 pnetwork
->network
.Length
);
891 cur_network
->aid
= pnetwork
->join_res
;
892 /*update fw_state will clr _FW_UNDER_LINKING*/
893 switch (pnetwork
->network
.InfrastructureMode
) {
894 case Ndis802_11Infrastructure
:
895 pmlmepriv
->fw_state
= WIFI_STATION_STATE
;
898 pmlmepriv
->fw_state
= WIFI_ADHOC_STATE
;
901 pmlmepriv
->fw_state
= WIFI_NULL_STATE
;
904 r8712_update_protection(adapter
,
905 (cur_network
->network
.IEs
) +
906 sizeof(struct NDIS_802_11_FIXED_IEs
),
907 (cur_network
->network
.IELength
));
908 /*TODO: update HT_Capability*/
909 update_ht_cap(adapter
, cur_network
->network
.IEs
,
910 cur_network
->network
.IELength
);
912 if (check_fwstate(pmlmepriv
, WIFI_STATION_STATE
)
914 r8712_indicate_connect(adapter
);
915 _cancel_timer(&pmlmepriv
->assoc_timer
,
918 goto ignore_joinbss_callback
;
920 if (check_fwstate(pmlmepriv
, _FW_UNDER_LINKING
) == true) {
921 _set_timer(&pmlmepriv
->assoc_timer
, 1);
922 _clr_fwstate_(pmlmepriv
, _FW_UNDER_LINKING
);
925 ignore_joinbss_callback
:
926 spin_unlock_irqrestore(&pmlmepriv
->lock
, irqL
);
927 if (sizeof(struct list_head
) == 4 * sizeof(u32
))
928 kfree((u8
*)pnetwork
);
931 void r8712_stassoc_event_callback(struct _adapter
*adapter
, u8
*pbuf
)
934 struct sta_info
*psta
;
935 struct mlme_priv
*pmlmepriv
= &(adapter
->mlmepriv
);
936 struct stassoc_event
*pstassoc
= (struct stassoc_event
*)pbuf
;
939 if (r8712_access_ctrl(&adapter
->acl_list
, pstassoc
->macaddr
) == false)
941 psta
= r8712_get_stainfo(&adapter
->stapriv
, pstassoc
->macaddr
);
943 /*the sta have been in sta_info_queue => do nothing
944 *(between drv has received this event before and
945 * fw have not yet to set key to CAM_ENTRY) */
949 psta
= r8712_alloc_stainfo(&adapter
->stapriv
, pstassoc
->macaddr
);
952 /* to do : init sta_info variable */
953 psta
->qos_option
= 0;
954 psta
->mac_id
= le32_to_cpu((uint
)pstassoc
->cam_id
);
955 /* psta->aid = (uint)pstassoc->cam_id; */
957 if (adapter
->securitypriv
.AuthAlgrthm
== 2)
958 psta
->XPrivacy
= adapter
->securitypriv
.PrivacyAlgrthm
;
959 psta
->ieee8021x_blocked
= false;
960 spin_lock_irqsave(&pmlmepriv
->lock
, irqL
);
961 if ((check_fwstate(pmlmepriv
, WIFI_ADHOC_MASTER_STATE
) == true) ||
962 (check_fwstate(pmlmepriv
, WIFI_ADHOC_STATE
) == true)) {
963 if (adapter
->stapriv
.asoc_sta_count
== 2) {
964 /* a sta + bc/mc_stainfo (not Ibss_stainfo) */
965 r8712_indicate_connect(adapter
);
968 spin_unlock_irqrestore(&pmlmepriv
->lock
, irqL
);
971 void r8712_stadel_event_callback(struct _adapter
*adapter
, u8
*pbuf
)
973 unsigned long irqL
, irqL2
;
974 struct sta_info
*psta
;
975 struct wlan_network
*pwlan
= NULL
;
976 struct wlan_bssid_ex
*pdev_network
= NULL
;
978 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
979 struct stadel_event
*pstadel
= (struct stadel_event
*)pbuf
;
980 struct sta_priv
*pstapriv
= &adapter
->stapriv
;
981 struct wlan_network
*tgt_network
= &pmlmepriv
->cur_network
;
983 spin_lock_irqsave(&pmlmepriv
->lock
, irqL2
);
984 if (check_fwstate(pmlmepriv
, WIFI_STATION_STATE
) == true) {
985 r8712_ind_disconnect(adapter
);
986 r8712_free_assoc_resources(adapter
);
988 if (check_fwstate(pmlmepriv
, WIFI_ADHOC_MASTER_STATE
|
990 psta
= r8712_get_stainfo(&adapter
->stapriv
, pstadel
->macaddr
);
991 spin_lock_irqsave(&pstapriv
->sta_hash_lock
, irqL
);
992 r8712_free_stainfo(adapter
, psta
);
993 spin_unlock_irqrestore(&pstapriv
->sta_hash_lock
, irqL
);
994 if (adapter
->stapriv
.asoc_sta_count
== 1) {
995 /*a sta + bc/mc_stainfo (not Ibss_stainfo) */
996 pwlan
= r8712_find_network(&pmlmepriv
->scanned_queue
,
997 tgt_network
->network
.MacAddress
);
999 pwlan
->fixed
= false;
1000 free_network_nolock(pmlmepriv
, pwlan
);
1003 pdev_network
= &(adapter
->registrypriv
.dev_network
);
1004 pibss
= adapter
->registrypriv
.dev_network
.MacAddress
;
1005 memcpy(pdev_network
, &tgt_network
->network
,
1006 r8712_get_ndis_wlan_bssid_ex_sz(&tgt_network
->
1008 memset(&pdev_network
->Ssid
, 0,
1009 sizeof(struct ndis_802_11_ssid
));
1010 memcpy(&pdev_network
->Ssid
,
1011 &pmlmepriv
->assoc_ssid
,
1012 sizeof(struct ndis_802_11_ssid
));
1013 r8712_update_registrypriv_dev_network(adapter
);
1014 r8712_generate_random_ibss(pibss
);
1015 if (check_fwstate(pmlmepriv
, WIFI_ADHOC_STATE
)) {
1016 _clr_fwstate_(pmlmepriv
, WIFI_ADHOC_STATE
);
1017 set_fwstate(pmlmepriv
, WIFI_ADHOC_MASTER_STATE
);
1021 spin_unlock_irqrestore(&pmlmepriv
->lock
, irqL2
);
1024 void r8712_cpwm_event_callback(struct _adapter
*adapter
, u8
*pbuf
)
1026 struct reportpwrstate_parm
*preportpwrstate
=
1027 (struct reportpwrstate_parm
*)pbuf
;
1029 preportpwrstate
->state
|= (u8
)(adapter
->pwrctrlpriv
.cpwm_tog
+ 0x80);
1030 r8712_cpwm_int_hdl(adapter
, preportpwrstate
);
1033 /* When the Netgear 3500 AP is with WPA2PSK-AES mode, it will send
1034 * the ADDBA req frame with start seq control = 0 to wifi client after
1035 * the WPA handshake and the seqence number of following data packet
1036 * will be 0. In this case, the Rx reorder sequence is not longer than 0
1037 * and the WiFi client will drop the data with seq number 0.
1038 * So, the 8712 firmware has to inform driver with receiving the
1039 * ADDBA-Req frame so that the driver can reset the
1040 * sequence value of Rx reorder contorl.
1042 void r8712_got_addbareq_event_callback(struct _adapter
*adapter
, u8
*pbuf
)
1044 struct ADDBA_Req_Report_parm
*pAddbareq_pram
=
1045 (struct ADDBA_Req_Report_parm
*)pbuf
;
1046 struct sta_info
*psta
;
1047 struct sta_priv
*pstapriv
= &adapter
->stapriv
;
1048 struct recv_reorder_ctrl
*precvreorder_ctrl
= NULL
;
1050 printk(KERN_INFO
"r8712u: [%s] mac = %pM, seq = %d, tid = %d\n",
1051 __func__
, pAddbareq_pram
->MacAddress
,
1052 pAddbareq_pram
->StartSeqNum
, pAddbareq_pram
->tid
);
1053 psta
= r8712_get_stainfo(pstapriv
, pAddbareq_pram
->MacAddress
);
1056 &psta
->recvreorder_ctrl
[pAddbareq_pram
->tid
];
1057 /* set the indicate_seq to 0xffff so that the rx reorder
1058 * can store any following data packet.
1060 precvreorder_ctrl
->indicate_seq
= 0xffff;
1064 void r8712_wpspbc_event_callback(struct _adapter
*adapter
, u8
*pbuf
)
1066 if (adapter
->securitypriv
.wps_hw_pbc_pressed
== false)
1067 adapter
->securitypriv
.wps_hw_pbc_pressed
= true;
1070 void _r8712_sitesurvey_ctrl_handler(struct _adapter
*adapter
)
1072 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
1073 struct sitesurvey_ctrl
*psitesurveyctrl
= &pmlmepriv
->sitesurveyctrl
;
1074 struct registry_priv
*pregistrypriv
= &adapter
->registrypriv
;
1075 u64 current_tx_pkts
;
1076 uint current_rx_pkts
;
1078 current_tx_pkts
= (adapter
->xmitpriv
.tx_pkts
) -
1079 (psitesurveyctrl
->last_tx_pkts
);
1080 current_rx_pkts
= (adapter
->recvpriv
.rx_pkts
) -
1081 (psitesurveyctrl
->last_rx_pkts
);
1082 psitesurveyctrl
->last_tx_pkts
= adapter
->xmitpriv
.tx_pkts
;
1083 psitesurveyctrl
->last_rx_pkts
= adapter
->recvpriv
.rx_pkts
;
1084 if ((current_tx_pkts
> pregistrypriv
->busy_thresh
) ||
1085 (current_rx_pkts
> pregistrypriv
->busy_thresh
))
1086 psitesurveyctrl
->traffic_busy
= true;
1088 psitesurveyctrl
->traffic_busy
= false;
1091 void _r8712_join_timeout_handler(struct _adapter
*adapter
)
1094 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
1096 if (adapter
->bDriverStopped
|| adapter
->bSurpriseRemoved
)
1098 spin_lock_irqsave(&pmlmepriv
->lock
, irqL
);
1099 _clr_fwstate_(pmlmepriv
, _FW_UNDER_LINKING
);
1100 pmlmepriv
->to_join
= false;
1101 if (check_fwstate(pmlmepriv
, _FW_LINKED
) == true) {
1102 r8712_os_indicate_disconnect(adapter
);
1103 _clr_fwstate_(pmlmepriv
, _FW_LINKED
);
1105 if (adapter
->pwrctrlpriv
.pwr_mode
!= adapter
->registrypriv
.power_mgnt
) {
1106 r8712_set_ps_mode(adapter
, adapter
->registrypriv
.power_mgnt
,
1107 adapter
->registrypriv
.smart_ps
);
1109 spin_unlock_irqrestore(&pmlmepriv
->lock
, irqL
);
1112 void r8712_scan_timeout_handler (struct _adapter
*adapter
)
1115 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
1117 spin_lock_irqsave(&pmlmepriv
->lock
, irqL
);
1118 _clr_fwstate_(pmlmepriv
, _FW_UNDER_SURVEY
);
1119 pmlmepriv
->to_join
= false; /* scan fail, so clear to_join flag */
1120 spin_unlock_irqrestore(&pmlmepriv
->lock
, irqL
);
1123 void _r8712_dhcp_timeout_handler (struct _adapter
*adapter
)
1125 if (adapter
->bDriverStopped
|| adapter
->bSurpriseRemoved
)
1127 if (adapter
->pwrctrlpriv
.pwr_mode
!= adapter
->registrypriv
.power_mgnt
)
1128 r8712_set_ps_mode(adapter
, adapter
->registrypriv
.power_mgnt
,
1129 adapter
->registrypriv
.smart_ps
);
1132 void _r8712_wdg_timeout_handler(struct _adapter
*adapter
)
1134 r8712_wdg_wk_cmd(adapter
);
1137 int r8712_select_and_join_from_scan(struct mlme_priv
*pmlmepriv
)
1139 struct list_head
*phead
;
1140 unsigned char *dst_ssid
, *src_ssid
;
1141 struct _adapter
*adapter
;
1142 struct __queue
*queue
= NULL
;
1143 struct wlan_network
*pnetwork
= NULL
;
1144 struct wlan_network
*pnetwork_max_rssi
= NULL
;
1146 adapter
= (struct _adapter
*)pmlmepriv
->nic_hdl
;
1147 queue
= &pmlmepriv
->scanned_queue
;
1148 phead
= get_list_head(queue
);
1149 pmlmepriv
->pscanned
= get_next(phead
);
1151 if (end_of_queue_search(phead
, pmlmepriv
->pscanned
) == true) {
1152 if ((pmlmepriv
->assoc_by_rssi
== true) &&
1153 (pnetwork_max_rssi
!= NULL
)) {
1154 pnetwork
= pnetwork_max_rssi
;
1155 goto ask_for_joinbss
;
1159 pnetwork
= LIST_CONTAINOR(pmlmepriv
->pscanned
,
1160 struct wlan_network
, list
);
1161 if (pnetwork
== NULL
)
1163 pmlmepriv
->pscanned
= get_next(pmlmepriv
->pscanned
);
1164 if (pmlmepriv
->assoc_by_bssid
== true) {
1165 dst_ssid
= pnetwork
->network
.MacAddress
;
1166 src_ssid
= pmlmepriv
->assoc_bssid
;
1167 if (!memcmp(dst_ssid
, src_ssid
, ETH_ALEN
)) {
1168 if (check_fwstate(pmlmepriv
, _FW_LINKED
)) {
1169 if (is_same_network(&pmlmepriv
->
1170 cur_network
.network
,
1171 &pnetwork
->network
)) {
1172 _clr_fwstate_(pmlmepriv
,
1174 /*r8712_indicate_connect again*/
1175 r8712_indicate_connect(adapter
);
1178 r8712_disassoc_cmd(adapter
);
1179 r8712_ind_disconnect(adapter
);
1180 r8712_free_assoc_resources(adapter
);
1182 goto ask_for_joinbss
;
1184 } else if (pmlmepriv
->assoc_ssid
.SsidLength
== 0)
1185 goto ask_for_joinbss
;
1186 dst_ssid
= pnetwork
->network
.Ssid
.Ssid
;
1187 src_ssid
= pmlmepriv
->assoc_ssid
.Ssid
;
1188 if ((pnetwork
->network
.Ssid
.SsidLength
==
1189 pmlmepriv
->assoc_ssid
.SsidLength
) &&
1190 (!memcmp(dst_ssid
, src_ssid
,
1191 pmlmepriv
->assoc_ssid
.SsidLength
))) {
1192 if (pmlmepriv
->assoc_by_rssi
== true) {
1193 /* if the ssid is the same, select the bss
1194 * which has the max rssi*/
1195 if (pnetwork_max_rssi
) {
1196 if (pnetwork
->network
.Rssi
>
1197 pnetwork_max_rssi
->network
.Rssi
)
1198 pnetwork_max_rssi
= pnetwork
;
1200 pnetwork_max_rssi
= pnetwork
;
1201 } else if (is_desired_network(adapter
, pnetwork
)) {
1202 if (check_fwstate(pmlmepriv
, _FW_LINKED
)) {
1203 r8712_disassoc_cmd(adapter
);
1204 r8712_free_assoc_resources(adapter
);
1206 goto ask_for_joinbss
;
1212 return r8712_joinbss_cmd(adapter
, pnetwork
);
1215 sint
r8712_set_auth(struct _adapter
*adapter
,
1216 struct security_priv
*psecuritypriv
)
1218 struct cmd_priv
*pcmdpriv
= &adapter
->cmdpriv
;
1219 struct cmd_obj
*pcmd
;
1220 struct setauth_parm
*psetauthparm
;
1221 sint ret
= _SUCCESS
;
1223 pcmd
= (struct cmd_obj
*)_malloc(sizeof(struct cmd_obj
));
1227 psetauthparm
= (struct setauth_parm
*)_malloc(
1228 sizeof(struct setauth_parm
));
1229 if (psetauthparm
== NULL
) {
1230 kfree((unsigned char *)pcmd
);
1233 memset(psetauthparm
, 0, sizeof(struct setauth_parm
));
1234 psetauthparm
->mode
= (u8
)psecuritypriv
->AuthAlgrthm
;
1235 pcmd
->cmdcode
= _SetAuth_CMD_
;
1236 pcmd
->parmbuf
= (unsigned char *)psetauthparm
;
1237 pcmd
->cmdsz
= sizeof(struct setauth_parm
);
1240 _init_listhead(&pcmd
->list
);
1241 r8712_enqueue_cmd(pcmdpriv
, pcmd
);
1245 sint
r8712_set_key(struct _adapter
*adapter
,
1246 struct security_priv
*psecuritypriv
,
1249 struct cmd_priv
*pcmdpriv
= &adapter
->cmdpriv
;
1250 struct cmd_obj
*pcmd
;
1251 struct setkey_parm
*psetkeyparm
;
1254 pcmd
= (struct cmd_obj
*)_malloc(sizeof(struct cmd_obj
));
1257 psetkeyparm
= (struct setkey_parm
*)_malloc(sizeof(struct setkey_parm
));
1258 if (psetkeyparm
== NULL
) {
1259 kfree((unsigned char *)pcmd
);
1262 memset(psetkeyparm
, 0, sizeof(struct setkey_parm
));
1263 if (psecuritypriv
->AuthAlgrthm
== 2) { /* 802.1X */
1264 psetkeyparm
->algorithm
=
1265 (u8
)psecuritypriv
->XGrpPrivacy
;
1267 psetkeyparm
->algorithm
=
1268 (u8
)psecuritypriv
->PrivacyAlgrthm
;
1270 psetkeyparm
->keyid
= (u8
)keyid
;
1272 switch (psetkeyparm
->algorithm
) {
1275 memcpy(psetkeyparm
->key
,
1276 psecuritypriv
->DefKey
[keyid
].skey
, keylen
);
1280 memcpy(psetkeyparm
->key
,
1281 psecuritypriv
->DefKey
[keyid
].skey
, keylen
);
1284 if (keyid
< 1 || keyid
> 2)
1287 memcpy(psetkeyparm
->key
,
1288 &psecuritypriv
->XGrpKey
[keyid
- 1], keylen
);
1289 psetkeyparm
->grpkey
= 1;
1292 if (keyid
< 1 || keyid
> 2)
1295 memcpy(psetkeyparm
->key
,
1296 &psecuritypriv
->XGrpKey
[keyid
- 1], keylen
);
1297 psetkeyparm
->grpkey
= 1;
1302 pcmd
->cmdcode
= _SetKey_CMD_
;
1303 pcmd
->parmbuf
= (u8
*)psetkeyparm
;
1304 pcmd
->cmdsz
= (sizeof(struct setkey_parm
));
1307 _init_listhead(&pcmd
->list
);
1308 r8712_enqueue_cmd(pcmdpriv
, pcmd
);
1312 /* adjust IEs for r8712_joinbss_cmd in WMM */
1313 int r8712_restruct_wmm_ie(struct _adapter
*adapter
, u8
*in_ie
, u8
*out_ie
,
1314 uint in_len
, uint initial_out_len
)
1316 unsigned int ielength
= 0;
1319 i
= 12; /* after the fixed IE */
1320 while (i
< in_len
) {
1321 ielength
= initial_out_len
;
1322 if (in_ie
[i
] == 0xDD && in_ie
[i
+ 2] == 0x00 &&
1323 in_ie
[i
+ 3] == 0x50 && in_ie
[i
+ 4] == 0xF2 &&
1324 in_ie
[i
+ 5] == 0x02 && i
+ 5 < in_len
) {
1325 /*WMM element ID and OUI*/
1326 for (j
= i
; j
< i
+ 9; j
++) {
1327 out_ie
[ielength
] = in_ie
[j
];
1330 out_ie
[initial_out_len
+ 1] = 0x07;
1331 out_ie
[initial_out_len
+ 6] = 0x00;
1332 out_ie
[initial_out_len
+ 8] = 0x00;
1335 i
+= (in_ie
[i
+ 1] + 2); /* to the next IE element */
1341 * Ported from 8185: IsInPreAuthKeyList().
1345 * -1 :if there is no pre-auth key in the table
1346 * >=0 :if there is pre-auth key, and return the entry id
1348 static int SecIsInPMKIDList(struct _adapter
*Adapter
, u8
*bssid
)
1350 struct security_priv
*psecuritypriv
= &Adapter
->securitypriv
;
1354 if (psecuritypriv
->PMKIDList
[i
].bUsed
&&
1355 (!memcmp(psecuritypriv
->PMKIDList
[i
].Bssid
,
1360 } while (i
< NUM_PMKID_CACHE
);
1362 if (i
== NUM_PMKID_CACHE
) {
1363 i
= -1; /* Could not find. */
1365 ; /* There is one Pre-Authentication Key for the
1366 * specific BSSID. */
1371 sint
r8712_restruct_sec_ie(struct _adapter
*adapter
, u8
*in_ie
,
1372 u8
*out_ie
, uint in_len
)
1374 u8 authmode
= 0, securitytype
, match
;
1375 u8 sec_ie
[255], uncst_oui
[4], bkup_ie
[255];
1376 u8 wpa_oui
[4] = {0x0, 0x50, 0xf2, 0x01};
1377 uint ielength
, cnt
, remove_cnt
;
1379 struct mlme_priv
*pmlmepriv
= &adapter
->mlmepriv
;
1380 struct security_priv
*psecuritypriv
= &adapter
->securitypriv
;
1381 uint ndisauthmode
= psecuritypriv
->ndisauthtype
;
1382 uint ndissecuritytype
= psecuritypriv
->ndisencryptstatus
;
1384 if ((ndisauthmode
== Ndis802_11AuthModeWPA
) ||
1385 (ndisauthmode
== Ndis802_11AuthModeWPAPSK
)) {
1386 authmode
= _WPA_IE_ID_
;
1388 uncst_oui
[1] = 0x50;
1389 uncst_oui
[2] = 0xf2;
1391 if ((ndisauthmode
== Ndis802_11AuthModeWPA2
) ||
1392 (ndisauthmode
== Ndis802_11AuthModeWPA2PSK
)) {
1393 authmode
= _WPA2_IE_ID_
;
1395 uncst_oui
[1] = 0x0f;
1396 uncst_oui
[2] = 0xac;
1398 switch (ndissecuritytype
) {
1399 case Ndis802_11Encryption1Enabled
:
1400 case Ndis802_11Encryption1KeyAbsent
:
1401 securitytype
= _WEP40_
;
1404 case Ndis802_11Encryption2Enabled
:
1405 case Ndis802_11Encryption2KeyAbsent
:
1406 securitytype
= _TKIP_
;
1409 case Ndis802_11Encryption3Enabled
:
1410 case Ndis802_11Encryption3KeyAbsent
:
1411 securitytype
= _AES_
;
1415 securitytype
= _NO_PRIVACY_
;
1418 /*Search required WPA or WPA2 IE and copy to sec_ie[] */
1421 while (cnt
< in_len
) {
1422 if (in_ie
[cnt
] == authmode
) {
1423 if ((authmode
== _WPA_IE_ID_
) &&
1424 (!memcmp(&in_ie
[cnt
+2], &wpa_oui
[0], 4))) {
1425 memcpy(&sec_ie
[0], &in_ie
[cnt
],
1426 in_ie
[cnt
+ 1] + 2);
1430 if (authmode
== _WPA2_IE_ID_
) {
1431 memcpy(&sec_ie
[0], &in_ie
[cnt
],
1432 in_ie
[cnt
+ 1] + 2);
1436 if (((authmode
== _WPA_IE_ID_
) &&
1437 (!memcmp(&in_ie
[cnt
+ 2], &wpa_oui
[0], 4))) ||
1438 (authmode
== _WPA2_IE_ID_
))
1439 memcpy(&bkup_ie
[0], &in_ie
[cnt
],
1440 in_ie
[cnt
+ 1] + 2);
1442 cnt
+= in_ie
[cnt
+1] + 2; /*get next*/
1444 /*restruct WPA IE or WPA2 IE in sec_ie[] */
1445 if (match
== true) {
1446 if (sec_ie
[0] == _WPA_IE_ID_
) {
1447 /* parsing SSN IE to select required encryption
1448 * algorithm, and set the bc/mc encryption algorithm */
1450 /*check wpa_oui tag*/
1451 if (memcmp(&sec_ie
[2], &wpa_oui
[0], 4)) {
1455 if ((sec_ie
[6] != 0x01) || (sec_ie
[7] != 0x0)) {
1460 if (!memcmp(&sec_ie
[8], &wpa_oui
[0], 3)) {
1461 /* get bc/mc encryption type (group
1463 switch (sec_ie
[11]) {
1465 psecuritypriv
->XGrpPrivacy
=
1468 case 0x1: /*WEP_40*/
1469 psecuritypriv
->XGrpPrivacy
=
1473 psecuritypriv
->XGrpPrivacy
=
1476 case 0x3: /*AESCCMP*/
1478 psecuritypriv
->XGrpPrivacy
=
1481 case 0x5: /*WEP_104*/
1482 psecuritypriv
->XGrpPrivacy
=
1490 if (sec_ie
[12] == 0x01) {
1491 /*check the unicast encryption type*/
1492 if (memcmp(&sec_ie
[14],
1493 &uncst_oui
[0], 4)) {
1497 } /*else the uncst_oui is match*/
1498 } else { /*mixed mode, unicast_enc_type > 1*/
1499 /*select the uncst_oui and remove
1500 * the other uncst_oui*/
1502 remove_cnt
= (cnt
-1) * 4;
1504 memcpy(&sec_ie
[14], &uncst_oui
[0], 4);
1505 /*remove the other unicast suit*/
1507 &sec_ie
[18 + remove_cnt
],
1508 sec_ie
[1] - 18 + 2 -
1510 sec_ie
[1] = sec_ie
[1] - remove_cnt
;
1515 if (authmode
== _WPA2_IE_ID_
) {
1516 /* parsing RSN IE to select required encryption
1517 * algorithm, and set the bc/mc encryption algorithm */
1519 if ((sec_ie
[2] != 0x01) || (sec_ie
[3] != 0x0)) {
1524 if (!memcmp(&sec_ie
[4], &uncst_oui
[0], 3)) {
1525 /*get bc/mc encryption type*/
1526 switch (sec_ie
[7]) {
1527 case 0x1: /*WEP_40*/
1528 psecuritypriv
->XGrpPrivacy
=
1532 psecuritypriv
->XGrpPrivacy
=
1535 case 0x4: /*AESWRAP*/
1536 psecuritypriv
->XGrpPrivacy
=
1539 case 0x5: /*WEP_104*/
1540 psecuritypriv
->XGrpPrivacy
=
1544 psecuritypriv
->XGrpPrivacy
=
1552 if (sec_ie
[8] == 0x01) {
1553 /*check the unicast encryption type*/
1554 if (memcmp(&sec_ie
[10],
1555 &uncst_oui
[0], 4)) {
1558 } /*else the uncst_oui is match*/
1559 } else { /*mixed mode, unicast_enc_type > 1*/
1560 /*select the uncst_oui and remove the
1563 remove_cnt
= (cnt
-1)*4;
1565 memcpy(&sec_ie
[10], &uncst_oui
[0], 4);
1566 /*remove the other unicast suit*/
1568 &sec_ie
[14 + remove_cnt
],
1569 (sec_ie
[1] - 14 + 2 -
1571 sec_ie
[1] = sec_ie
[1]-remove_cnt
;
1577 if ((authmode
== _WPA_IE_ID_
) || (authmode
== _WPA2_IE_ID_
)) {
1579 memcpy(out_ie
, in_ie
, 12);
1582 if (match
== true) {
1583 memcpy(&out_ie
[ielength
], &sec_ie
[0], sec_ie
[1]+2);
1584 ielength
+= sec_ie
[1] + 2;
1585 if (authmode
== _WPA2_IE_ID_
) {
1586 /*the Pre-Authentication bit should be zero*/
1587 out_ie
[ielength
- 1] = 0;
1588 out_ie
[ielength
- 2] = 0;
1590 r8712_report_sec_ie(adapter
, authmode
, sec_ie
);
1593 /*copy fixed ie only*/
1594 memcpy(out_ie
, in_ie
, 12);
1596 if (psecuritypriv
->wps_phase
== true) {
1597 memcpy(out_ie
+ielength
, psecuritypriv
->wps_ie
,
1598 psecuritypriv
->wps_ie_len
);
1599 ielength
+= psecuritypriv
->wps_ie_len
;
1602 iEntry
= SecIsInPMKIDList(adapter
, pmlmepriv
->assoc_bssid
);
1606 if (authmode
== _WPA2_IE_ID_
) {
1607 out_ie
[ielength
] = 1;
1609 out_ie
[ielength
] = 0; /*PMKID count = 0x0100*/
1611 memcpy(&out_ie
[ielength
],
1612 &psecuritypriv
->PMKIDList
[iEntry
].PMKID
, 16);
1614 out_ie
[13] += 18;/*PMKID length = 2+16*/
1620 void r8712_init_registrypriv_dev_network(struct _adapter
*adapter
)
1622 struct registry_priv
*pregistrypriv
= &adapter
->registrypriv
;
1623 struct eeprom_priv
*peepriv
= &adapter
->eeprompriv
;
1624 struct wlan_bssid_ex
*pdev_network
= &pregistrypriv
->dev_network
;
1625 u8
*myhwaddr
= myid(peepriv
);
1627 memcpy(pdev_network
->MacAddress
, myhwaddr
, ETH_ALEN
);
1628 memcpy(&pdev_network
->Ssid
, &pregistrypriv
->ssid
,
1629 sizeof(struct ndis_802_11_ssid
));
1630 pdev_network
->Configuration
.Length
=
1631 sizeof(struct NDIS_802_11_CONFIGURATION
);
1632 pdev_network
->Configuration
.BeaconPeriod
= 100;
1633 pdev_network
->Configuration
.FHConfig
.Length
= 0;
1634 pdev_network
->Configuration
.FHConfig
.HopPattern
= 0;
1635 pdev_network
->Configuration
.FHConfig
.HopSet
= 0;
1636 pdev_network
->Configuration
.FHConfig
.DwellTime
= 0;
1639 void r8712_update_registrypriv_dev_network(struct _adapter
*adapter
)
1642 struct registry_priv
*pregistrypriv
= &adapter
->registrypriv
;
1643 struct wlan_bssid_ex
*pdev_network
= &pregistrypriv
->dev_network
;
1644 struct security_priv
*psecuritypriv
= &adapter
->securitypriv
;
1645 struct wlan_network
*cur_network
= &adapter
->mlmepriv
.cur_network
;
1647 pdev_network
->Privacy
= cpu_to_le32(psecuritypriv
->PrivacyAlgrthm
1648 > 0 ? 1 : 0) ; /* adhoc no 802.1x */
1649 pdev_network
->Rssi
= 0;
1650 switch (pregistrypriv
->wireless_mode
) {
1652 pdev_network
->NetworkTypeInUse
= cpu_to_le32(Ndis802_11DS
);
1656 pdev_network
->NetworkTypeInUse
= cpu_to_le32(Ndis802_11OFDM24
);
1659 pdev_network
->NetworkTypeInUse
= cpu_to_le32(Ndis802_11OFDM5
);
1665 pdev_network
->Configuration
.DSConfig
= cpu_to_le32(
1666 pregistrypriv
->channel
);
1667 if (cur_network
->network
.InfrastructureMode
== Ndis802_11IBSS
)
1668 pdev_network
->Configuration
.ATIMWindow
= cpu_to_le32(3);
1669 pdev_network
->InfrastructureMode
= cpu_to_le32(
1670 cur_network
->network
.InfrastructureMode
);
1671 /* 1. Supported rates
1674 sz
= r8712_generate_ie(pregistrypriv
);
1675 pdev_network
->IELength
= sz
;
1676 pdev_network
->Length
= r8712_get_ndis_wlan_bssid_ex_sz(
1677 (struct ndis_wlan_bssid_ex
*)pdev_network
);
1680 /*the function is at passive_level*/
1681 void r8712_joinbss_reset(struct _adapter
*padapter
)
1684 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1685 struct ht_priv
*phtpriv
= &pmlmepriv
->htpriv
;
1687 /* todo: if you want to do something io/reg/hw setting before join_bss,
1688 * please add code here */
1689 phtpriv
->ampdu_enable
= false;/*reset to disabled*/
1690 for (i
= 0; i
< 16; i
++)
1691 phtpriv
->baddbareq_issued
[i
] = false;/*reset it*/
1692 if (phtpriv
->ht_option
) {
1693 /* validate usb rx aggregation */
1694 r8712_write8(padapter
, 0x102500D9, 48);/*TH = 48 pages, 6k*/
1696 /* invalidate usb rx aggregation */
1697 /* TH=1 => means that invalidate usb rx aggregation */
1698 r8712_write8(padapter
, 0x102500D9, 1);
1702 /*the function is >= passive_level*/
1703 unsigned int r8712_restructure_ht_ie(struct _adapter
*padapter
, u8
*in_ie
,
1704 u8
*out_ie
, uint in_len
, uint
*pout_len
)
1707 unsigned char *p
, *pframe
;
1708 struct ieee80211_ht_cap ht_capie
;
1709 unsigned char WMM_IE
[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
1710 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1711 struct qos_priv
*pqospriv
= &pmlmepriv
->qospriv
;
1712 struct ht_priv
*phtpriv
= &pmlmepriv
->htpriv
;
1714 phtpriv
->ht_option
= 0;
1715 p
= r8712_get_ie(in_ie
+12, _HT_CAPABILITY_IE_
, &ielen
, in_len
-12);
1716 if (p
&& (ielen
> 0)) {
1717 if (pqospriv
->qos_option
== 0) {
1718 out_len
= *pout_len
;
1719 pframe
= r8712_set_ie(out_ie
+out_len
,
1720 _VENDOR_SPECIFIC_IE_
,
1723 pqospriv
->qos_option
= 1;
1725 out_len
= *pout_len
;
1726 memset(&ht_capie
, 0, sizeof(struct ieee80211_ht_cap
));
1727 ht_capie
.cap_info
= IEEE80211_HT_CAP_SUP_WIDTH
|
1728 IEEE80211_HT_CAP_SGI_20
|
1729 IEEE80211_HT_CAP_SGI_40
|
1730 IEEE80211_HT_CAP_TX_STBC
|
1731 IEEE80211_HT_CAP_MAX_AMSDU
|
1732 IEEE80211_HT_CAP_DSSSCCK40
;
1733 ht_capie
.ampdu_params_info
= (IEEE80211_HT_CAP_AMPDU_FACTOR
&
1734 0x03) | (IEEE80211_HT_CAP_AMPDU_DENSITY
& 0x00);
1735 pframe
= r8712_set_ie(out_ie
+out_len
, _HT_CAPABILITY_IE_
,
1736 sizeof(struct ieee80211_ht_cap
),
1737 (unsigned char *)&ht_capie
, pout_len
);
1738 phtpriv
->ht_option
= 1;
1740 return phtpriv
->ht_option
;
1743 /* the function is > passive_level (in critical_section) */
1744 static void update_ht_cap(struct _adapter
*padapter
, u8
*pie
, uint ie_len
)
1746 u8
*p
, max_ampdu_sz
;
1748 struct sta_info
*bmc_sta
, *psta
;
1749 struct ieee80211_ht_cap
*pht_capie
;
1750 struct ieee80211_ht_addt_info
*pht_addtinfo
;
1751 struct recv_reorder_ctrl
*preorder_ctrl
;
1752 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1753 struct ht_priv
*phtpriv
= &pmlmepriv
->htpriv
;
1754 struct registry_priv
*pregistrypriv
= &padapter
->registrypriv
;
1755 struct wlan_network
*pcur_network
= &(pmlmepriv
->cur_network
);
1757 if (!phtpriv
->ht_option
)
1759 /* maybe needs check if ap supports rx ampdu. */
1760 if ((phtpriv
->ampdu_enable
== false) &&
1761 (pregistrypriv
->ampdu_enable
== 1))
1762 phtpriv
->ampdu_enable
= true;
1763 /*check Max Rx A-MPDU Size*/
1765 p
= r8712_get_ie(pie
+ sizeof(struct NDIS_802_11_FIXED_IEs
),
1768 sizeof(struct NDIS_802_11_FIXED_IEs
));
1770 pht_capie
= (struct ieee80211_ht_cap
*)(p
+2);
1771 max_ampdu_sz
= (pht_capie
->ampdu_params_info
&
1772 IEEE80211_HT_CAP_AMPDU_FACTOR
);
1773 /* max_ampdu_sz (kbytes); */
1774 max_ampdu_sz
= 1 << (max_ampdu_sz
+3);
1775 phtpriv
->rx_ampdu_maxlen
= max_ampdu_sz
;
1777 /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info
1778 * if A-MPDU Rx is enabled, reseting rx_ordering_ctrl
1779 * wstart_b(indicate_seq) to default value=0xffff
1780 * todo: check if AP can send A-MPDU packets
1782 bmc_sta
= r8712_get_bcmc_stainfo(padapter
);
1784 for (i
= 0; i
< 16; i
++) {
1785 preorder_ctrl
= &bmc_sta
->recvreorder_ctrl
[i
];
1786 preorder_ctrl
->indicate_seq
= 0xffff;
1787 preorder_ctrl
->wend_b
= 0xffff;
1790 psta
= r8712_get_stainfo(&padapter
->stapriv
,
1791 pcur_network
->network
.MacAddress
);
1793 for (i
= 0; i
< 16 ; i
++) {
1794 preorder_ctrl
= &psta
->recvreorder_ctrl
[i
];
1795 preorder_ctrl
->indicate_seq
= 0xffff;
1796 preorder_ctrl
->wend_b
= 0xffff;
1800 p
= r8712_get_ie(pie
+ sizeof(struct NDIS_802_11_FIXED_IEs
),
1801 _HT_ADD_INFO_IE_
, &len
,
1802 ie_len
-sizeof(struct NDIS_802_11_FIXED_IEs
));
1804 pht_addtinfo
= (struct ieee80211_ht_addt_info
*)(p
+ 2);
1807 void r8712_issue_addbareq_cmd(struct _adapter
*padapter
, int priority
)
1809 struct mlme_priv
*pmlmepriv
= &padapter
->mlmepriv
;
1810 struct ht_priv
*phtpriv
= &pmlmepriv
->htpriv
;
1812 if ((phtpriv
->ht_option
== 1) && (phtpriv
->ampdu_enable
== true)) {
1813 if (phtpriv
->baddbareq_issued
[priority
] == false) {
1814 r8712_addbareq_cmd(padapter
, (u8
)priority
);
1815 phtpriv
->baddbareq_issued
[priority
] = true;