2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Purpose: Handles the Basic Service Set & Node Database functions
24 * BSSpSearchBSSList - Search known BSS list for Desire SSID or BSSID
25 * BSSvClearBSSList - Clear BSS List
26 * BSSbInsertToBSSList - Insert a BSS set into known BSS list
27 * BSSbUpdateToBSSList - Update BSS set in known BSS list
28 * BSSDBbIsSTAInNodeDB - Search Node DB table to find the index of matched DstAddr
29 * BSSvCreateOneNode - Allocate an Node for Node DB
30 * BSSvUpdateAPNode - Update AP Node content in Index 0 of KnownNodeDB
31 * BSSvSecondCallBack - One second timer callback function to update Node DB info & AP link status
32 * BSSvUpdateNodeTxCounter - Update Tx attemps, Tx failure counter in Node DB for auto-fall back rate control
43 #if !defined(__TBIT_H__)
46 #if !defined(__TTYPE_H__)
49 #if !defined(__TMACRO_H__)
52 #if !defined(__TETHER_H__)
55 #if !defined(__DEVICE_H__)
58 #if !defined(__80211HDR_H__)
61 #if !defined(__BSSDB_H__)
64 #if !defined(__WMGR_H__)
67 #if !defined(__DATARATE_H__)
70 #if !defined(__DESC_H__)
73 #if !defined(__WCMD_H__)
76 #if !defined(__WPA_H__)
79 #if !defined(__BASEBAND_H__)
82 #if !defined(__RF_H__)
85 #if !defined(__CARD_H__)
88 #if !defined(__MAC_H__)
91 #if !defined(__WPA2_H__)
94 #if !defined(__UMEM_H__)
98 #if !defined(__IOWPA_H__)
102 //#define PLICE_DEBUG
103 /*--------------------- Static Definitions -------------------------*/
108 /*--------------------- Static Classes ----------------------------*/
110 /*--------------------- Static Variables --------------------------*/
111 static int msglevel
=MSG_LEVEL_INFO
;
112 //static int msglevel =MSG_LEVEL_DEBUG;
116 const WORD awHWRetry0
[5][5] = {
117 {RATE_18M
, RATE_18M
, RATE_12M
, RATE_12M
, RATE_12M
},
118 {RATE_24M
, RATE_24M
, RATE_18M
, RATE_12M
, RATE_12M
},
119 {RATE_36M
, RATE_36M
, RATE_24M
, RATE_18M
, RATE_18M
},
120 {RATE_48M
, RATE_48M
, RATE_36M
, RATE_24M
, RATE_24M
},
121 {RATE_54M
, RATE_54M
, RATE_48M
, RATE_36M
, RATE_36M
}
123 const WORD awHWRetry1
[5][5] = {
124 {RATE_18M
, RATE_18M
, RATE_12M
, RATE_6M
, RATE_6M
},
125 {RATE_24M
, RATE_24M
, RATE_18M
, RATE_6M
, RATE_6M
},
126 {RATE_36M
, RATE_36M
, RATE_24M
, RATE_12M
, RATE_12M
},
127 {RATE_48M
, RATE_48M
, RATE_24M
, RATE_12M
, RATE_12M
},
128 {RATE_54M
, RATE_54M
, RATE_36M
, RATE_18M
, RATE_18M
}
133 /*--------------------- Static Functions --------------------------*/
135 VOID
s_vCheckSensitivity(
136 IN HANDLE hDeviceContext
139 #ifdef Calcu_LinkQual
140 VOID
s_uCalculateLinkQual(
141 IN HANDLE hDeviceContext
146 VOID
s_vCheckPreEDThreshold(
147 IN HANDLE hDeviceContext
149 /*--------------------- Export Variables --------------------------*/
152 /*--------------------- Export Functions --------------------------*/
160 * Routine Description:
161 * Search known BSS list for Desire SSID or BSSID.
164 * PTR to KnownBSS or NULL
170 IN HANDLE hDeviceContext
,
171 IN PBYTE pbyDesireBSSID
,
172 IN PBYTE pbyDesireSSID
,
173 IN CARD_PHY_TYPE ePhyType
176 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
177 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
178 PBYTE pbyBSSID
= NULL
;
179 PWLAN_IE_SSID pSSID
= NULL
;
180 PKnownBSS pCurrBSS
= NULL
;
181 PKnownBSS pSelect
= NULL
;
182 BYTE ZeroBSSID
[WLAN_BSSID_LEN
]={0x00,0x00,0x00,0x00,0x00,0x00};
184 // UINT jj = 0; //DavidWang
185 if (pbyDesireBSSID
!= NULL
) {
186 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BSSpSearchBSSList BSSID[%02X %02X %02X-%02X %02X %02X]\n",
187 *pbyDesireBSSID
,*(pbyDesireBSSID
+1),*(pbyDesireBSSID
+2),
188 *(pbyDesireBSSID
+3),*(pbyDesireBSSID
+4),*(pbyDesireBSSID
+5));
189 if ((!IS_BROADCAST_ADDRESS(pbyDesireBSSID
)) &&
190 (memcmp(pbyDesireBSSID
, ZeroBSSID
, 6)!= 0)) {
191 pbyBSSID
= pbyDesireBSSID
;
194 if (pbyDesireSSID
!= NULL
) {
195 if (((PWLAN_IE_SSID
)pbyDesireSSID
)->len
!= 0) {
196 pSSID
= (PWLAN_IE_SSID
) pbyDesireSSID
;
200 if (pbyBSSID
!= NULL
) {
202 for (ii
= 0; ii
<MAX_BSS_NUM
; ii
++) {
203 pCurrBSS
= &(pMgmt
->sBSSList
[ii
]);
204 if(pDevice
->bLinkPass
==FALSE
) pCurrBSS
->bSelected
= FALSE
;
205 if ((pCurrBSS
->bActive
) &&
206 (pCurrBSS
->bSelected
== FALSE
)) {
207 if (IS_ETH_ADDRESS_EQUAL(pCurrBSS
->abyBSSID
, pbyBSSID
)) {
210 if (MEMEqualMemory(pSSID
->abySSID
,
211 ((PWLAN_IE_SSID
)pCurrBSS
->abySSID
)->abySSID
,
213 if ((pMgmt
->eConfigMode
== WMAC_CONFIG_AUTO
) ||
214 ((pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS
->wCapInfo
)) ||
215 ((pMgmt
->eConfigMode
== WMAC_CONFIG_ESS_STA
) && WLAN_GET_CAP_INFO_ESS(pCurrBSS
->wCapInfo
))
217 pCurrBSS
->bSelected
= TRUE
;
222 if ((pMgmt
->eConfigMode
== WMAC_CONFIG_AUTO
) ||
223 ((pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS
->wCapInfo
)) ||
224 ((pMgmt
->eConfigMode
== WMAC_CONFIG_ESS_STA
) && WLAN_GET_CAP_INFO_ESS(pCurrBSS
->wCapInfo
))
226 pCurrBSS
->bSelected
= TRUE
;
235 for (ii
= 0; ii
<MAX_BSS_NUM
; ii
++) {
236 pCurrBSS
= &(pMgmt
->sBSSList
[ii
]);
237 //2007-0721-01<Add>by MikeLiu
238 pCurrBSS
->bSelected
= FALSE
;
239 if (pCurrBSS
->bActive
) {
243 if (!MEMEqualMemory(pSSID
->abySSID
,
244 ((PWLAN_IE_SSID
)pCurrBSS
->abySSID
)->abySSID
,
246 (pSSID
->len
!= ((PWLAN_IE_SSID
)pCurrBSS
->abySSID
)->len
)) {
247 // SSID not match skip this BSS
251 if (((pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) && WLAN_GET_CAP_INFO_ESS(pCurrBSS
->wCapInfo
)) ||
252 ((pMgmt
->eConfigMode
== WMAC_CONFIG_ESS_STA
) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS
->wCapInfo
))
254 // Type not match skip this BSS
255 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BSS type mismatch.... Config[%d] BSS[0x%04x]\n", pMgmt
->eConfigMode
, pCurrBSS
->wCapInfo
);
259 if (ePhyType
!= PHY_TYPE_AUTO
) {
260 if (((ePhyType
== PHY_TYPE_11A
) && (PHY_TYPE_11A
!= pCurrBSS
->eNetworkTypeInUse
)) ||
261 ((ePhyType
!= PHY_TYPE_11A
) && (PHY_TYPE_11A
== pCurrBSS
->eNetworkTypeInUse
))) {
262 // PhyType not match skip this BSS
263 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Physical type mismatch.... ePhyType[%d] BSS[%d]\n", ePhyType
, pCurrBSS
->eNetworkTypeInUse
);
268 if (pMgmt->eAuthenMode < WMAC_AUTH_WPA) {
269 if (pCurrBSS->bWPAValid == TRUE) {
270 // WPA AP will reject connection of station without WPA enable.
273 } else if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
274 (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) {
275 if (pCurrBSS->bWPAValid == FALSE) {
276 // station with WPA enable can't join NonWPA AP.
279 } else if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
280 (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
281 if (pCurrBSS->bWPA2Valid == FALSE) {
282 // station with WPA2 enable can't join NonWPA2 AP.
287 if (pSelect
== NULL
) {
290 // compare RSSI, select signal strong one
291 if (pCurrBSS
->uRSSI
< pSelect
->uRSSI
) {
297 if (pSelect
!= NULL
) {
298 pSelect
->bSelected
= TRUE
;
300 if (pDevice->bRoaming == FALSE) {
301 // Einsn Add @20070907
302 ZERO_MEMORY(pbyDesireSSID, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
303 MEMvCopy(pbyDesireSSID,pCurrBSS->abySSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1) ;
316 * Routine Description:
327 IN HANDLE hDeviceContext
,
328 IN BOOL bKeepCurrBSSID
331 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
332 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
335 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
336 if (bKeepCurrBSSID
) {
337 if (pMgmt
->sBSSList
[ii
].bActive
&&
338 IS_ETH_ADDRESS_EQUAL(pMgmt
->sBSSList
[ii
].abyBSSID
, pMgmt
->abyCurrBSSID
)) {
339 // bKeepCurrBSSID = FALSE;
344 if ((pMgmt
->sBSSList
[ii
].bActive
) && (pMgmt
->sBSSList
[ii
].uClearCount
< BSS_CLEAR_COUNT
)) {
345 pMgmt
->sBSSList
[ii
].uClearCount
++;
349 pMgmt
->sBSSList
[ii
].bActive
= FALSE
;
350 memset(&pMgmt
->sBSSList
[ii
], 0, sizeof(KnownBSS
));
352 BSSvClearAnyBSSJoinRecord(pDevice
);
361 * Routine Description:
362 * search BSS list by BSSID & SSID if matched
370 IN HANDLE hDeviceContext
,
372 IN PWLAN_IE_SSID pSSID
375 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
376 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
377 PKnownBSS pBSSList
= NULL
;
380 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
381 pBSSList
= &(pMgmt
->sBSSList
[ii
]);
382 if (pBSSList
->bActive
) {
383 if (IS_ETH_ADDRESS_EQUAL(pBSSList
->abyBSSID
, abyBSSID
)) {
384 // if (pSSID == NULL)
386 if (pSSID
->len
== ((PWLAN_IE_SSID
)pBSSList
->abySSID
)->len
){
387 if (memcmp(pSSID
->abySSID
,
388 ((PWLAN_IE_SSID
)pBSSList
->abySSID
)->abySSID
,
404 * Routine Description:
405 * Insert a BSS set into known BSS list
413 BSSbInsertToBSSList (
414 IN HANDLE hDeviceContext
,
415 IN PBYTE abyBSSIDAddr
,
416 IN QWORD qwTimestamp
,
417 IN WORD wBeaconInterval
,
419 IN BYTE byCurrChannel
,
420 IN PWLAN_IE_SSID pSSID
,
421 IN PWLAN_IE_SUPP_RATES pSuppRates
,
422 IN PWLAN_IE_SUPP_RATES pExtSuppRates
,
424 IN PWLAN_IE_RSN pRSN
,
425 IN PWLAN_IE_RSN_EXT pRSNWPA
,
426 IN PWLAN_IE_COUNTRY pIE_Country
,
427 IN PWLAN_IE_QUIET pIE_Quiet
,
430 IN HANDLE pRxPacketContext
434 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
435 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
436 PSRxMgmtPacket pRxPacket
= (PSRxMgmtPacket
)pRxPacketContext
;
437 PKnownBSS pBSSList
= NULL
;
439 BOOL bParsingQuiet
= FALSE
;
440 PWLAN_IE_QUIET pQuiet
= NULL
;
444 pBSSList
= (PKnownBSS
)&(pMgmt
->sBSSList
[0]);
446 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
447 pBSSList
= (PKnownBSS
)&(pMgmt
->sBSSList
[ii
]);
448 if (!pBSSList
->bActive
)
452 if (ii
== MAX_BSS_NUM
){
453 DEVICE_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Get free KnowBSS node failed.\n");
457 pBSSList
->bActive
= TRUE
;
458 memcpy( pBSSList
->abyBSSID
, abyBSSIDAddr
, WLAN_BSSID_LEN
);
459 HIDWORD(pBSSList
->qwBSSTimestamp
) = cpu_to_le32(HIDWORD(qwTimestamp
));
460 LODWORD(pBSSList
->qwBSSTimestamp
) = cpu_to_le32(LODWORD(qwTimestamp
));
461 pBSSList
->wBeaconInterval
= cpu_to_le16(wBeaconInterval
);
462 pBSSList
->wCapInfo
= cpu_to_le16(wCapInfo
);
463 pBSSList
->uClearCount
= 0;
465 if (pSSID
->len
> WLAN_SSID_MAXLEN
)
466 pSSID
->len
= WLAN_SSID_MAXLEN
;
467 memcpy( pBSSList
->abySSID
, pSSID
, pSSID
->len
+ WLAN_IEHDR_LEN
);
469 pBSSList
->uChannel
= byCurrChannel
;
471 if (pSuppRates
->len
> WLAN_RATES_MAXLEN
)
472 pSuppRates
->len
= WLAN_RATES_MAXLEN
;
473 memcpy( pBSSList
->abySuppRates
, pSuppRates
, pSuppRates
->len
+ WLAN_IEHDR_LEN
);
475 if (pExtSuppRates
!= NULL
) {
476 if (pExtSuppRates
->len
> WLAN_RATES_MAXLEN
)
477 pExtSuppRates
->len
= WLAN_RATES_MAXLEN
;
478 memcpy(pBSSList
->abyExtSuppRates
, pExtSuppRates
, pExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
479 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BSSbInsertToBSSList: pExtSuppRates->len = %d\n", pExtSuppRates
->len
);
482 memset(pBSSList
->abyExtSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
484 pBSSList
->sERP
.byERP
= psERP
->byERP
;
485 pBSSList
->sERP
.bERPExist
= psERP
->bERPExist
;
487 // Check if BSS is 802.11a/b/g
488 if (pBSSList
->uChannel
> CB_MAX_CHANNEL_24G
) {
489 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11A
;
491 if (pBSSList
->sERP
.bERPExist
== TRUE
) {
492 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11G
;
494 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11B
;
498 pBSSList
->byRxRate
= pRxPacket
->byRxRate
;
499 pBSSList
->qwLocalTSF
= pRxPacket
->qwLocalTSF
;
500 pBSSList
->uRSSI
= pRxPacket
->uRSSI
;
501 pBSSList
->bySQ
= pRxPacket
->bySQ
;
503 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
504 (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
506 if (pBSSList
== pMgmt
->pCurrBSS
) {
507 bParsingQuiet
= TRUE
;
511 WPA_ClearRSN(pBSSList
);
513 if (pRSNWPA
!= NULL
) {
514 UINT uLen
= pRSNWPA
->len
+ 2;
516 if (uLen
<= (uIELength
- (UINT
)(ULONG_PTR
)((PBYTE
)pRSNWPA
- pbyIEs
))) {
517 pBSSList
->wWPALen
= uLen
;
518 memcpy(pBSSList
->byWPAIE
, pRSNWPA
, uLen
);
519 WPA_ParseRSN(pBSSList
, pRSNWPA
);
523 WPA2_ClearRSN(pBSSList
);
526 UINT uLen
= pRSN
->len
+ 2;
527 if (uLen
<= (uIELength
- (UINT
)(ULONG_PTR
)((PBYTE
)pRSN
- pbyIEs
))) {
528 pBSSList
->wRSNLen
= uLen
;
529 memcpy(pBSSList
->byRSNIE
, pRSN
, uLen
);
530 WPA2vParseRSN(pBSSList
, pRSN
);
534 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) || (pBSSList
->bWPA2Valid
== TRUE
)) {
536 PSKeyItem pTransmitKey
= NULL
;
537 BOOL bIs802_1x
= FALSE
;
539 for (ii
= 0; ii
< pBSSList
->wAKMSSAuthCount
; ii
++) {
540 if (pBSSList
->abyAKMSSAuthType
[ii
] == WLAN_11i_AKMSS_802_1X
) {
545 if ((bIs802_1x
== TRUE
) && (pSSID
->len
== ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->len
) &&
546 (MEMEqualMemory(pSSID
->abySSID
, ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->abySSID
, pSSID
->len
))) {
548 bAdd_PMKID_Candidate((HANDLE
)pDevice
, pBSSList
->abyBSSID
, &pBSSList
->sRSNCapObj
);
550 if ((pDevice
->bLinkPass
== TRUE
) && (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
551 if ((KeybGetTransmitKey(&(pDevice
->sKey
), pDevice
->abyBSSID
, PAIRWISE_KEY
, &pTransmitKey
) == TRUE
) ||
552 (KeybGetTransmitKey(&(pDevice
->sKey
), pDevice
->abyBSSID
, GROUP_KEY
, &pTransmitKey
) == TRUE
)) {
553 pDevice
->gsPMKIDCandidate
.StatusType
= Ndis802_11StatusType_PMKID_CandidateList
;
554 pDevice
->gsPMKIDCandidate
.Version
= 1;
562 if (pDevice
->bUpdateBBVGA
) {
563 // Moniter if RSSI is too strong.
564 pBSSList
->byRSSIStatCnt
= 0;
565 RFvRSSITodBm(pDevice
, (BYTE
)(pRxPacket
->uRSSI
), &pBSSList
->ldBmMAX
);
566 pBSSList
->ldBmAverage
[0] = pBSSList
->ldBmMAX
;
567 for (ii
= 1; ii
< RSSI_STAT_COUNT
; ii
++)
568 pBSSList
->ldBmAverage
[ii
] = 0;
571 if ((pIE_Country
!= NULL
) &&
572 (pMgmt
->b11hEnable
== TRUE
)) {
573 CARDvSetCountryInfo(pMgmt
->pAdapter
,
574 pBSSList
->eNetworkTypeInUse
,
580 if ((bParsingQuiet
== TRUE
) && (pIE_Quiet
!= NULL
)) {
581 if ((((PWLAN_IE_QUIET
)pIE_Quiet
)->len
== 8) &&
582 (((PWLAN_IE_QUIET
)pIE_Quiet
)->byQuietCount
!= 0)) {
584 if (pQuiet
== NULL
) {
585 pQuiet
= (PWLAN_IE_QUIET
)pIE_Quiet
;
586 CARDbSetQuiet( pMgmt
->pAdapter
,
588 pQuiet
->byQuietCount
,
589 pQuiet
->byQuietPeriod
,
590 *((PWORD
)pQuiet
->abyQuietDuration
),
591 *((PWORD
)pQuiet
->abyQuietOffset
)
594 pQuiet
= (PWLAN_IE_QUIET
)pIE_Quiet
;
595 CARDbSetQuiet( pMgmt
->pAdapter
,
597 pQuiet
->byQuietCount
,
598 pQuiet
->byQuietPeriod
,
599 *((PWORD
)pQuiet
->abyQuietDuration
),
600 *((PWORD
)pQuiet
->abyQuietOffset
)
606 if ((bParsingQuiet
== TRUE
) &&
608 CARDbStartQuiet(pMgmt
->pAdapter
);
611 pBSSList
->uIELength
= uIELength
;
612 if (pBSSList
->uIELength
> WLAN_BEACON_FR_MAXLEN
)
613 pBSSList
->uIELength
= WLAN_BEACON_FR_MAXLEN
;
614 MEMvCopy(pBSSList
->abyIEs
, pbyIEs
, pBSSList
->uIELength
);
622 * Routine Description:
623 * Update BSS set in known BSS list
629 // TODO: input structure modify
632 BSSbUpdateToBSSList (
633 IN HANDLE hDeviceContext
,
634 IN QWORD qwTimestamp
,
635 IN WORD wBeaconInterval
,
637 IN BYTE byCurrChannel
,
639 IN PWLAN_IE_SSID pSSID
,
640 IN PWLAN_IE_SUPP_RATES pSuppRates
,
641 IN PWLAN_IE_SUPP_RATES pExtSuppRates
,
643 IN PWLAN_IE_RSN pRSN
,
644 IN PWLAN_IE_RSN_EXT pRSNWPA
,
645 IN PWLAN_IE_COUNTRY pIE_Country
,
646 IN PWLAN_IE_QUIET pIE_Quiet
,
647 IN PKnownBSS pBSSList
,
650 IN HANDLE pRxPacketContext
654 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
655 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
656 PSRxMgmtPacket pRxPacket
= (PSRxMgmtPacket
)pRxPacketContext
;
658 BOOL bParsingQuiet
= FALSE
;
659 PWLAN_IE_QUIET pQuiet
= NULL
;
663 if (pBSSList
== NULL
)
666 HIDWORD(pBSSList
->qwBSSTimestamp
) = cpu_to_le32(HIDWORD(qwTimestamp
));
667 LODWORD(pBSSList
->qwBSSTimestamp
) = cpu_to_le32(LODWORD(qwTimestamp
));
668 pBSSList
->wBeaconInterval
= cpu_to_le16(wBeaconInterval
);
669 pBSSList
->wCapInfo
= cpu_to_le16(wCapInfo
);
670 pBSSList
->uClearCount
= 0;
671 pBSSList
->uChannel
= byCurrChannel
;
672 // DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSbUpdateToBSSList: pBSSList->uChannel: %d\n", pBSSList->uChannel);
674 if (pSSID
->len
> WLAN_SSID_MAXLEN
)
675 pSSID
->len
= WLAN_SSID_MAXLEN
;
677 if ((pSSID
->len
!= 0) && (pSSID
->abySSID
[0] != 0))
678 memcpy(pBSSList
->abySSID
, pSSID
, pSSID
->len
+ WLAN_IEHDR_LEN
);
679 memcpy(pBSSList
->abySuppRates
, pSuppRates
,pSuppRates
->len
+ WLAN_IEHDR_LEN
);
681 if (pExtSuppRates
!= NULL
) {
682 memcpy(pBSSList
->abyExtSuppRates
, pExtSuppRates
,pExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
684 memset(pBSSList
->abyExtSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
686 pBSSList
->sERP
.byERP
= psERP
->byERP
;
687 pBSSList
->sERP
.bERPExist
= psERP
->bERPExist
;
689 // Check if BSS is 802.11a/b/g
690 if (pBSSList
->uChannel
> CB_MAX_CHANNEL_24G
) {
691 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11A
;
693 if (pBSSList
->sERP
.bERPExist
== TRUE
) {
694 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11G
;
696 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11B
;
700 pBSSList
->byRxRate
= pRxPacket
->byRxRate
;
701 pBSSList
->qwLocalTSF
= pRxPacket
->qwLocalTSF
;
703 pBSSList
->uRSSI
= pRxPacket
->uRSSI
;
704 pBSSList
->bySQ
= pRxPacket
->bySQ
;
706 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
707 (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
709 if (pBSSList
== pMgmt
->pCurrBSS
) {
710 bParsingQuiet
= TRUE
;
714 WPA_ClearRSN(pBSSList
); //mike update
716 if (pRSNWPA
!= NULL
) {
717 UINT uLen
= pRSNWPA
->len
+ 2;
718 if (uLen
<= (uIELength
- (UINT
)(ULONG_PTR
)((PBYTE
)pRSNWPA
- pbyIEs
))) {
719 pBSSList
->wWPALen
= uLen
;
720 memcpy(pBSSList
->byWPAIE
, pRSNWPA
, uLen
);
721 WPA_ParseRSN(pBSSList
, pRSNWPA
);
725 WPA2_ClearRSN(pBSSList
); //mike update
728 UINT uLen
= pRSN
->len
+ 2;
729 if (uLen
<= (uIELength
- (UINT
)(ULONG_PTR
)((PBYTE
)pRSN
- pbyIEs
))) {
730 pBSSList
->wRSNLen
= uLen
;
731 memcpy(pBSSList
->byRSNIE
, pRSN
, uLen
);
732 WPA2vParseRSN(pBSSList
, pRSN
);
736 if (pRxPacket
->uRSSI
!= 0) {
737 RFvRSSITodBm(pDevice
, (BYTE
)(pRxPacket
->uRSSI
), &ldBm
);
738 // Moniter if RSSI is too strong.
739 pBSSList
->byRSSIStatCnt
++;
740 pBSSList
->byRSSIStatCnt
%= RSSI_STAT_COUNT
;
741 pBSSList
->ldBmAverage
[pBSSList
->byRSSIStatCnt
] = ldBm
;
742 for(ii
=0;ii
<RSSI_STAT_COUNT
;ii
++) {
743 if (pBSSList
->ldBmAverage
[ii
] != 0) {
744 pBSSList
->ldBmMAX
= max(pBSSList
->ldBmAverage
[ii
], ldBm
);
749 if ((pIE_Country
!= NULL
) &&
750 (pMgmt
->b11hEnable
== TRUE
)) {
751 CARDvSetCountryInfo(pMgmt
->pAdapter
,
752 pBSSList
->eNetworkTypeInUse
,
756 if ((bParsingQuiet
== TRUE
) && (pIE_Quiet
!= NULL
)) {
757 if ((((PWLAN_IE_QUIET
)pIE_Quiet
)->len
== 8) &&
758 (((PWLAN_IE_QUIET
)pIE_Quiet
)->byQuietCount
!= 0)) {
760 if (pQuiet
== NULL
) {
761 pQuiet
= (PWLAN_IE_QUIET
)pIE_Quiet
;
762 CARDbSetQuiet( pMgmt
->pAdapter
,
764 pQuiet
->byQuietCount
,
765 pQuiet
->byQuietPeriod
,
766 *((PWORD
)pQuiet
->abyQuietDuration
),
767 *((PWORD
)pQuiet
->abyQuietOffset
)
770 pQuiet
= (PWLAN_IE_QUIET
)pIE_Quiet
;
771 CARDbSetQuiet( pMgmt
->pAdapter
,
773 pQuiet
->byQuietCount
,
774 pQuiet
->byQuietPeriod
,
775 *((PWORD
)pQuiet
->abyQuietDuration
),
776 *((PWORD
)pQuiet
->abyQuietOffset
)
782 if ((bParsingQuiet
== TRUE
) &&
784 CARDbStartQuiet(pMgmt
->pAdapter
);
787 pBSSList
->uIELength
= uIELength
;
788 if (pBSSList
->uIELength
> WLAN_BEACON_FR_MAXLEN
)
789 pBSSList
->uIELength
= WLAN_BEACON_FR_MAXLEN
;
790 memcpy(pBSSList
->abyIEs
, pbyIEs
, pBSSList
->uIELength
);
801 * Routine Description:
802 * Search Node DB table to find the index of matched DstAddr
811 IN PVOID pMgmtObject
,
813 OUT PUINT puNodeIndex
816 PSMgmtObject pMgmt
= (PSMgmtObject
) pMgmtObject
;
819 // Index = 0 reserved for AP Node
820 for (ii
= 1; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
821 if (pMgmt
->sNodeDBTable
[ii
].bActive
) {
822 if (IS_ETH_ADDRESS_EQUAL(abyDstAddr
, pMgmt
->sNodeDBTable
[ii
].abyMACAddr
)) {
836 * Routine Description:
837 * Find an empty node and allocated; if no empty found,
838 * instand used of most inactive one.
846 IN HANDLE hDeviceContext
,
847 OUT PUINT puNodeIndex
851 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
852 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
854 UINT BigestCount
= 0;
857 // Index = 0 reserved for AP Node (In STA mode)
858 // Index = 0 reserved for Broadcast/MultiCast (In AP mode)
860 for (ii
= 1; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
861 if (pMgmt
->sNodeDBTable
[ii
].bActive
) {
862 if (pMgmt
->sNodeDBTable
[ii
].uInActiveCount
> BigestCount
) {
863 BigestCount
= pMgmt
->sNodeDBTable
[ii
].uInActiveCount
;
872 // if not found replace uInActiveCount is largest one.
873 if ( ii
== (MAX_NODE_NUM
+ 1)) {
874 *puNodeIndex
= SelectIndex
;
875 DEVICE_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Replace inactive node = %d\n", SelectIndex
);
877 if (pMgmt
->sNodeDBTable
[*puNodeIndex
].sTxPSQueue
.next
!= NULL
) {
878 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[*puNodeIndex
].sTxPSQueue
)) != NULL
)
886 memset(&pMgmt
->sNodeDBTable
[*puNodeIndex
], 0, sizeof(KnownNodeDB
));
887 pMgmt
->sNodeDBTable
[*puNodeIndex
].bActive
= TRUE
;
888 pMgmt
->sNodeDBTable
[*puNodeIndex
].uRatePollTimeout
= FALLBACK_POLL_SECOND
;
889 // for AP mode PS queue
890 skb_queue_head_init(&pMgmt
->sNodeDBTable
[*puNodeIndex
].sTxPSQueue
);
891 pMgmt
->sNodeDBTable
[*puNodeIndex
].byAuthSequence
= 0;
892 pMgmt
->sNodeDBTable
[*puNodeIndex
].wEnQueueCnt
= 0;
893 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Create node index = %d\n", ii
);
901 * Routine Description:
902 * Remove Node by NodeIndex
911 IN HANDLE hDeviceContext
,
916 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
917 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
918 BYTE byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
922 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[uNodeIndex
].sTxPSQueue
)) != NULL
)
925 memset(&pMgmt
->sNodeDBTable
[uNodeIndex
], 0, sizeof(KnownNodeDB
));
927 pMgmt
->abyPSTxMap
[pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
>> 3] &= ~byMask
[pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
& 7];
933 * Routine Description:
934 * Update AP Node content in Index 0 of KnownNodeDB
944 IN HANDLE hDeviceContext
,
946 IN PWLAN_IE_SUPP_RATES pSuppRates
,
947 IN PWLAN_IE_SUPP_RATES pExtSuppRates
950 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
951 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
952 UINT uRateLen
= WLAN_RATES_MAXLEN
;
954 memset(&pMgmt
->sNodeDBTable
[0], 0, sizeof(KnownNodeDB
));
956 pMgmt
->sNodeDBTable
[0].bActive
= TRUE
;
957 if (pDevice
->eCurrentPHYType
== PHY_TYPE_11B
) {
958 uRateLen
= WLAN_RATES_MAXLEN_11B
;
960 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pSuppRates
,
961 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
963 pMgmt
->abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pExtSuppRates
,
964 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
966 RATEvParseMaxRate((PVOID
) pDevice
,
967 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
968 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
970 &(pMgmt
->sNodeDBTable
[0].wMaxBasicRate
),
971 &(pMgmt
->sNodeDBTable
[0].wMaxSuppRate
),
972 &(pMgmt
->sNodeDBTable
[0].wSuppRate
),
973 &(pMgmt
->sNodeDBTable
[0].byTopCCKBasicRate
),
974 &(pMgmt
->sNodeDBTable
[0].byTopOFDMBasicRate
)
976 memcpy(pMgmt
->sNodeDBTable
[0].abyMACAddr
, pMgmt
->abyCurrBSSID
, WLAN_ADDR_LEN
);
977 pMgmt
->sNodeDBTable
[0].wTxDataRate
= pMgmt
->sNodeDBTable
[0].wMaxSuppRate
;
978 pMgmt
->sNodeDBTable
[0].bShortPreamble
= WLAN_GET_CAP_INFO_SHORTPREAMBLE(*pwCapInfo
);
979 pMgmt
->sNodeDBTable
[0].uRatePollTimeout
= FALLBACK_POLL_SECOND
;
981 printk("BSSvUpdateAPNode:MaxSuppRate is %d\n",pMgmt
->sNodeDBTable
[0].wMaxSuppRate
);
983 // Auto rate fallback function initiation.
984 // RATEbInit(pDevice);
985 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"pMgmt->sNodeDBTable[0].wTxDataRate = %d \n", pMgmt
->sNodeDBTable
[0].wTxDataRate
);
995 * Routine Description:
996 * Add Multicast Node content in Index 0 of KnownNodeDB
1006 BSSvAddMulticastNode(
1007 IN HANDLE hDeviceContext
1010 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1011 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
1013 if (!pDevice
->bEnableHostWEP
)
1014 memset(&pMgmt
->sNodeDBTable
[0], 0, sizeof(KnownNodeDB
));
1015 memset(pMgmt
->sNodeDBTable
[0].abyMACAddr
, 0xff, WLAN_ADDR_LEN
);
1016 pMgmt
->sNodeDBTable
[0].bActive
= TRUE
;
1017 pMgmt
->sNodeDBTable
[0].bPSEnable
= FALSE
;
1018 skb_queue_head_init(&pMgmt
->sNodeDBTable
[0].sTxPSQueue
);
1019 RATEvParseMaxRate((PVOID
) pDevice
,
1020 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
1021 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
1023 &(pMgmt
->sNodeDBTable
[0].wMaxBasicRate
),
1024 &(pMgmt
->sNodeDBTable
[0].wMaxSuppRate
),
1025 &(pMgmt
->sNodeDBTable
[0].wSuppRate
),
1026 &(pMgmt
->sNodeDBTable
[0].byTopCCKBasicRate
),
1027 &(pMgmt
->sNodeDBTable
[0].byTopOFDMBasicRate
)
1029 pMgmt
->sNodeDBTable
[0].wTxDataRate
= pMgmt
->sNodeDBTable
[0].wMaxBasicRate
;
1031 printk("BSSvAddMultiCastNode:pMgmt->sNodeDBTable[0].wTxDataRate is %d\n",pMgmt
->sNodeDBTable
[0].wTxDataRate
);
1033 pMgmt
->sNodeDBTable
[0].uRatePollTimeout
= FALLBACK_POLL_SECOND
;
1043 * Routine Description:
1046 * Second call back function to update Node DB info & AP link status
1053 //2008-4-14 <add> by chester for led issue
1054 #ifdef FOR_LED_ON_NOTEBOOK
1060 IN HANDLE hDeviceContext
1063 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1064 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
1066 PWLAN_IE_SSID pItemSSID
, pCurrSSID
;
1067 UINT uSleepySTACnt
= 0;
1068 UINT uNonShortSlotSTACnt
= 0;
1069 UINT uLongPreambleSTACnt
= 0;
1070 viawget_wpa_header
* wpahdr
;
1072 spin_lock_irq(&pDevice
->lock
);
1074 pDevice
->uAssocCount
= 0;
1076 pDevice
->byERPFlag
&=
1077 ~(WLAN_SET_ERP_BARKER_MODE(1) | WLAN_SET_ERP_NONERP_PRESENT(1));
1078 //2008-4-14 <add> by chester for led issue
1079 #ifdef FOR_LED_ON_NOTEBOOK
1080 MACvGPIOIn(pDevice
->PortOffset
, &pDevice
->byGPIO
);
1081 if (((BITbIsBitOff(pDevice
->byGPIO
,GPIO0_DATA
)&&(pDevice
->bHWRadioOff
== FALSE
))||(BITbIsBitOn(pDevice
->byGPIO
,GPIO0_DATA
)&&(pDevice
->bHWRadioOff
== TRUE
)))&&(cc
==FALSE
)){
1086 if(pDevice
->bHWRadioOff
== TRUE
){
1087 if (BITbIsBitOff(pDevice
->byGPIO
,GPIO0_DATA
))
1088 //||(BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA) && BITbIsBitOn(pDevice->byRadioCtl, EEP_RADIOCTL_INV)))
1089 {if(status
==1) goto start
;
1091 CARDbRadioPowerOff(pDevice
);
1092 pMgmt
->sNodeDBTable
[0].bActive
= FALSE
;
1093 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
1094 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1095 //netif_stop_queue(pDevice->dev);
1096 pDevice
->bLinkPass
= FALSE
;
1099 if (BITbIsBitOn(pDevice
->byGPIO
,GPIO0_DATA
))
1100 //||(BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA) && BITbIsBitOn(pDevice->byRadioCtl, EEP_RADIOCTL_INV)))
1101 {if(status
==2) goto start
;
1103 CARDbRadioPowerOn(pDevice
);
1106 if (BITbIsBitOn(pDevice
->byGPIO
,GPIO0_DATA
))
1107 //||(BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA) && BITbIsBitOn(pDevice->byRadioCtl, EEP_RADIOCTL_INV)))
1108 {if(status
==3) goto start
;
1110 CARDbRadioPowerOff(pDevice
);
1111 pMgmt
->sNodeDBTable
[0].bActive
= FALSE
;
1112 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
1113 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1114 //netif_stop_queue(pDevice->dev);
1115 pDevice
->bLinkPass
= FALSE
;
1118 if (BITbIsBitOff(pDevice
->byGPIO
,GPIO0_DATA
))
1119 //||(BITbIsBitOff(pDevice->byGPIO,GPIO0_DATA) && BITbIsBitOn(pDevice->byRadioCtl, EEP_RADIOCTL_INV)))
1120 {if(status
==4) goto start
;
1122 CARDbRadioPowerOn(pDevice
);
1129 if (pDevice
->wUseProtectCntDown
> 0) {
1130 pDevice
->wUseProtectCntDown
--;
1133 // disable protect mode
1134 pDevice
->byERPFlag
&= ~(WLAN_SET_ERP_USE_PROTECTION(1));
1138 pDevice
->byReAssocCount
++;
1139 if((pDevice
->byReAssocCount
> 10) && (pDevice
->bLinkPass
!= TRUE
)) { //10 sec timeout
1140 printk("Re-association timeout!!!\n");
1141 pDevice
->byReAssocCount
= 0;
1142 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1143 // if(pDevice->bWPASuppWextEnabled == TRUE)
1145 union iwreq_data wrqu
;
1146 memset(&wrqu
, 0, sizeof (wrqu
));
1147 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1148 printk("wireless_send_event--->SIOCGIWAP(disassociated)\n");
1149 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1153 else if(pDevice
->bLinkPass
== TRUE
)
1154 pDevice
->byReAssocCount
= 0;
1157 #ifdef Calcu_LinkQual
1158 s_uCalculateLinkQual((HANDLE
)pDevice
);
1161 for (ii
= 0; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
1163 if (pMgmt
->sNodeDBTable
[ii
].bActive
) {
1165 // Increase in-activity counter
1166 pMgmt
->sNodeDBTable
[ii
].uInActiveCount
++;
1169 if (pMgmt
->sNodeDBTable
[ii
].uInActiveCount
> MAX_INACTIVE_COUNT
) {
1170 BSSvRemoveOneNode(pDevice
, ii
);
1171 DEVICE_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
1172 "Inactive timeout [%d] sec, STA index = [%d] remove\n", MAX_INACTIVE_COUNT
, ii
);
1176 if (pMgmt
->sNodeDBTable
[ii
].eNodeState
>= NODE_ASSOC
) {
1178 pDevice
->uAssocCount
++;
1180 // check if Non ERP exist
1181 if (pMgmt
->sNodeDBTable
[ii
].uInActiveCount
< ERP_RECOVER_COUNT
) {
1182 if (!pMgmt
->sNodeDBTable
[ii
].bShortPreamble
) {
1183 pDevice
->byERPFlag
|= WLAN_SET_ERP_BARKER_MODE(1);
1184 uLongPreambleSTACnt
++;
1186 if (!pMgmt
->sNodeDBTable
[ii
].bERPExist
) {
1187 pDevice
->byERPFlag
|= WLAN_SET_ERP_NONERP_PRESENT(1);
1188 pDevice
->byERPFlag
|= WLAN_SET_ERP_USE_PROTECTION(1);
1190 if (!pMgmt
->sNodeDBTable
[ii
].bShortSlotTime
)
1191 uNonShortSlotSTACnt
++;
1195 // check if any STA in PS mode
1196 if (pMgmt
->sNodeDBTable
[ii
].bPSEnable
)
1202 // Rate fallback check
1204 if (!pDevice
->bFixRate
) {
1206 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (ii == 0))
1207 RATEvTxRateFallBack(pDevice, &(pMgmt->sNodeDBTable[ii]));
1210 // ii = 0 for multicast node (AP & Adhoc)
1211 RATEvTxRateFallBack((PVOID
)pDevice
, &(pMgmt
->sNodeDBTable
[ii
]));
1214 // ii = 0 reserved for unicast AP node (Infra STA)
1215 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
)
1217 printk("SecondCallback:Before:TxDataRate is %d\n",pMgmt
->sNodeDBTable
[0].wTxDataRate
);
1219 RATEvTxRateFallBack((PVOID
)pDevice
, &(pMgmt
->sNodeDBTable
[ii
]));
1221 printk("SecondCallback:After:TxDataRate is %d\n",pMgmt
->sNodeDBTable
[0].wTxDataRate
);
1228 // check if pending PS queue
1229 if (pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
!= 0) {
1230 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Index= %d, Queue = %d pending \n",
1231 ii
, pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
);
1232 if ((ii
>0) && (pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
> 15)) {
1233 BSSvRemoveOneNode(pDevice
, ii
);
1234 DEVICE_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Pending many queues PS STA Index = %d remove \n", ii
);
1243 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) && (pDevice
->eCurrentPHYType
== PHY_TYPE_11G
)) {
1245 // on/off protect mode
1246 if (WLAN_GET_ERP_USE_PROTECTION(pDevice
->byERPFlag
)) {
1247 if (!pDevice
->bProtectMode
) {
1248 MACvEnableProtectMD(pDevice
->PortOffset
);
1249 pDevice
->bProtectMode
= TRUE
;
1253 if (pDevice
->bProtectMode
) {
1254 MACvDisableProtectMD(pDevice
->PortOffset
);
1255 pDevice
->bProtectMode
= FALSE
;
1258 // on/off short slot time
1260 if (uNonShortSlotSTACnt
> 0) {
1261 if (pDevice
->bShortSlotTime
) {
1262 pDevice
->bShortSlotTime
= FALSE
;
1263 BBvSetShortSlotTime(pDevice
);
1264 vUpdateIFS((PVOID
)pDevice
);
1268 if (!pDevice
->bShortSlotTime
) {
1269 pDevice
->bShortSlotTime
= TRUE
;
1270 BBvSetShortSlotTime(pDevice
);
1271 vUpdateIFS((PVOID
)pDevice
);
1275 // on/off barker long preamble mode
1277 if (uLongPreambleSTACnt
> 0) {
1278 if (!pDevice
->bBarkerPreambleMd
) {
1279 MACvEnableBarkerPreambleMd(pDevice
->PortOffset
);
1280 pDevice
->bBarkerPreambleMd
= TRUE
;
1284 if (pDevice
->bBarkerPreambleMd
) {
1285 MACvDisableBarkerPreambleMd(pDevice
->PortOffset
);
1286 pDevice
->bBarkerPreambleMd
= FALSE
;
1293 // Check if any STA in PS mode, enable DTIM multicast deliver
1294 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
1295 if (uSleepySTACnt
> 0)
1296 pMgmt
->sNodeDBTable
[0].bPSEnable
= TRUE
;
1298 pMgmt
->sNodeDBTable
[0].bPSEnable
= FALSE
;
1301 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
1302 pCurrSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
1303 //printk("pCurrSSID=%s\n",pCurrSSID->abySSID);
1304 if ((pMgmt
->eCurrMode
== WMAC_MODE_STANDBY
) ||
1305 (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
)) {
1307 if (pMgmt
->sNodeDBTable
[0].bActive
) { // Assoc with BSS
1308 // DEVICE_PRT(MSG_LEVEL_INFO, KERN_INFO "Callback inactive Count = [%d]\n", pMgmt->sNodeDBTable[0].uInActiveCount);
1309 //if (pDevice->bUpdateBBVGA) {
1310 // s_vCheckSensitivity((HANDLE) pDevice);
1312 if (pDevice
->bUpdateBBVGA
) {
1313 // s_vCheckSensitivity((HANDLE) pDevice);
1314 s_vCheckPreEDThreshold((HANDLE
)pDevice
);
1316 if ((pMgmt
->sNodeDBTable
[0].uInActiveCount
>= (LOST_BEACON_COUNT
/2)) &&
1317 (pDevice
->byBBVGACurrent
!= pDevice
->abyBBVGA
[0]) ) {
1318 pDevice
->byBBVGANew
= pDevice
->abyBBVGA
[0];
1319 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_CHANGE_BBSENSITIVITY
, NULL
);
1323 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
>= LOST_BEACON_COUNT
) {
1324 pMgmt
->sNodeDBTable
[0].bActive
= FALSE
;
1325 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
1326 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1327 netif_stop_queue(pDevice
->dev
);
1328 pDevice
->bLinkPass
= FALSE
;
1329 pDevice
->bRoaming
= TRUE
;
1330 DEVICE_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Lost AP beacon [%d] sec, disconnected !\n", pMgmt
->sNodeDBTable
[0].uInActiveCount
);
1331 if ((pDevice
->bWPADEVUp
) && (pDevice
->skb
!= NULL
)) {
1332 wpahdr
= (viawget_wpa_header
*)pDevice
->skb
->data
;
1333 wpahdr
->type
= VIAWGET_DISASSOC_MSG
;
1334 wpahdr
->resp_ie_len
= 0;
1335 wpahdr
->req_ie_len
= 0;
1336 skb_put(pDevice
->skb
, sizeof(viawget_wpa_header
));
1337 pDevice
->skb
->dev
= pDevice
->wpadev
;
1338 pDevice
->skb
->mac_header
= pDevice
->skb
->data
;
1339 pDevice
->skb
->pkt_type
= PACKET_HOST
;
1340 pDevice
->skb
->protocol
= htons(ETH_P_802_2
);
1341 memset(pDevice
->skb
->cb
, 0, sizeof(pDevice
->skb
->cb
));
1342 netif_rx(pDevice
->skb
);
1343 pDevice
->skb
= dev_alloc_skb((int)pDevice
->rx_buf_sz
);
1345 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1346 // if(pDevice->bWPASuppWextEnabled == TRUE)
1348 union iwreq_data wrqu
;
1349 memset(&wrqu
, 0, sizeof (wrqu
));
1350 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1351 printk("wireless_send_event--->SIOCGIWAP(disassociated)\n");
1352 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1357 else if (pItemSSID
->len
!= 0) {
1358 if (pDevice
->uAutoReConnectTime
< 10) {
1359 pDevice
->uAutoReConnectTime
++;
1360 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1361 //network manager support need not do Roaming scan???
1362 if(pDevice
->bWPASuppWextEnabled
==TRUE
)
1363 pDevice
->uAutoReConnectTime
= 0;
1368 //mike use old encryption status for wpa reauthen
1369 if(pDevice
->bWPADEVUp
)
1370 pDevice
->eEncryptionStatus
= pDevice
->eOldEncryptionStatus
;
1371 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Roaming ...\n");
1372 BSSvClearBSSList((HANDLE
)pDevice
, pDevice
->bLinkPass
);
1373 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
1374 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, pMgmt
->abyDesireSSID
);
1375 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_SSID
, pMgmt
->abyDesireSSID
);
1376 pDevice
->uAutoReConnectTime
= 0;
1381 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
1382 // if adhoc started which essid is NULL string, rescaning.
1383 if ((pMgmt
->eCurrState
== WMAC_STATE_STARTED
) && (pCurrSSID
->len
== 0)) {
1384 if (pDevice
->uAutoReConnectTime
< 10) {
1385 pDevice
->uAutoReConnectTime
++;
1388 DEVICE_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Adhoc re-scaning ...\n");
1389 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
1390 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_BSSID_SCAN
, NULL
);
1391 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_SSID
, NULL
);
1392 pDevice
->uAutoReConnectTime
= 0;
1395 if (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
) {
1396 if (pDevice
->bUpdateBBVGA
) {
1397 //s_vCheckSensitivity((HANDLE) pDevice);
1398 s_vCheckPreEDThreshold((HANDLE
)pDevice
);
1400 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
>=ADHOC_LOST_BEACON_COUNT
) {
1401 DEVICE_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Lost other STA beacon [%d] sec, started !\n", pMgmt
->sNodeDBTable
[0].uInActiveCount
);
1402 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
1403 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
1404 netif_stop_queue(pDevice
->dev
);
1405 pDevice
->bLinkPass
= FALSE
;
1410 spin_unlock_irq(&pDevice
->lock
);
1412 pMgmt
->sTimerSecondCallback
.expires
= RUN_AT(HZ
);
1413 add_timer(&pMgmt
->sTimerSecondCallback
);
1422 * Routine Description:
1425 * Update Tx attemps, Tx failure counter in Node DB
1436 BSSvUpdateNodeTxCounter(
1437 IN HANDLE hDeviceContext
,
1441 IN UINT uFIFOHeaderSize
1444 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1445 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
1446 UINT uNodeIndex
= 0;
1447 BYTE byTxRetry
= (byTsr0
& TSR0_NCR
);
1448 PSTxBufHead pTxBufHead
;
1449 PS802_11Header pMACHeader
;
1451 WORD wFallBackRate
= RATE_1M
;
1454 // UINT txRetryTemp;
1456 //txRetryTemp = byTxRetry;
1457 //if (txRetryTemp== 8)
1460 pTxBufHead
= (PSTxBufHead
) pbyBuffer
;
1461 if (pTxBufHead
->wFIFOCtl
& FIFOCTL_AUTO_FB_0
) {
1462 byFallBack
= AUTO_FB_0
;
1463 } else if (pTxBufHead
->wFIFOCtl
& FIFOCTL_AUTO_FB_1
) {
1464 byFallBack
= AUTO_FB_1
;
1466 byFallBack
= AUTO_FB_NONE
;
1468 wRate
= pTxBufHead
->wReserved
; //?wRate
1469 //printk("BSSvUpdateNodeTxCounter:byTxRetry is %d\n",byTxRetry);
1471 //printk("BSSvUpdateNodeTx:wRate is %d,byFallback is %d\n",wRate,byFallBack);
1472 //#ifdef PLICE_DEBUG
1473 //printk("BSSvUpdateNodeTx: wRate is %d\n",wRate);
1475 // Only Unicast using support rates
1476 if (pTxBufHead
->wFIFOCtl
& FIFOCTL_NEEDACK
) {
1477 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wRate %04X, byTsr0 %02X, byTsr1 %02X\n", wRate
, byTsr0
, byTsr1
);
1478 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) {
1479 pMgmt
->sNodeDBTable
[0].uTxAttempts
+= 1;
1480 if ((byTsr1
& TSR1_TERR
) == 0) {
1481 // transmit success, TxAttempts at least plus one
1482 pMgmt
->sNodeDBTable
[0].uTxOk
[MAX_RATE
]++;
1483 if ( (byFallBack
== AUTO_FB_NONE
) ||
1484 (wRate
< RATE_18M
) ) {
1485 wFallBackRate
= wRate
;
1486 } else if (byFallBack
== AUTO_FB_0
) {
1489 //if (txRetryTemp < 5)
1490 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][byTxRetry
];
1491 //wFallBackRate = awHWRetry0[wRate-RATE_12M][byTxRetry];
1492 //wFallBackRate = awHWRetry0[wRate-RATE_18M][txRetryTemp] +1;
1494 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][4];
1495 //wFallBackRate = awHWRetry0[wRate-RATE_12M][4];
1496 } else if (byFallBack
== AUTO_FB_1
) {
1498 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][byTxRetry
];
1500 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][4];
1502 pMgmt
->sNodeDBTable
[0].uTxOk
[wFallBackRate
]++;
1504 pMgmt
->sNodeDBTable
[0].uTxFailures
++;
1506 pMgmt
->sNodeDBTable
[0].uTxRetry
+= byTxRetry
;
1507 if (byTxRetry
!= 0) {
1508 pMgmt
->sNodeDBTable
[0].uTxFail
[MAX_RATE
]+=byTxRetry
;
1509 if ( (byFallBack
== AUTO_FB_NONE
) ||
1510 (wRate
< RATE_18M
) ) {
1511 pMgmt
->sNodeDBTable
[0].uTxFail
[wRate
]+=byTxRetry
;
1512 } else if (byFallBack
== AUTO_FB_0
) {
1514 for(ii
=0;ii
<byTxRetry
;ii
++)
1515 //for (ii=0;ii<txRetryTemp;ii++)
1521 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][ii
];
1522 //printk(" II is %d:BSSvUpdateNodeTx:wFallBackRate is %d\n",ii,wFallBackRate);
1523 //wFallBackRate = awHWRetry0[wRate-RATE_12M][ii];
1527 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][4];
1528 //printk("ii is %d BSSvUpdateNodeTx:wFallBackRate is %d\n",ii,wFallBackRate);
1529 //wFallBackRate = awHWRetry0[wRate-RATE_12M][4];
1531 pMgmt
->sNodeDBTable
[0].uTxFail
[wFallBackRate
]++;
1533 } else if (byFallBack
== AUTO_FB_1
) {
1534 for(ii
=0;ii
<byTxRetry
;ii
++) {
1536 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][ii
];
1538 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][4];
1539 pMgmt
->sNodeDBTable
[0].uTxFail
[wFallBackRate
]++;
1545 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) ||
1546 (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
)) {
1548 pMACHeader
= (PS802_11Header
)(pbyBuffer
+ uFIFOHeaderSize
);
1550 if (BSSDBbIsSTAInNodeDB((HANDLE
)pMgmt
, &(pMACHeader
->abyAddr1
[0]), &uNodeIndex
)){
1551 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxAttempts
+= 1;
1552 if ((byTsr1
& TSR1_TERR
) == 0) {
1553 // transmit success, TxAttempts at least plus one
1554 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxOk
[MAX_RATE
]++;
1555 if ( (byFallBack
== AUTO_FB_NONE
) ||
1556 (wRate
< RATE_18M
) ) {
1557 wFallBackRate
= wRate
;
1558 } else if (byFallBack
== AUTO_FB_0
) {
1560 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][byTxRetry
];
1562 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][4];
1563 } else if (byFallBack
== AUTO_FB_1
) {
1565 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][byTxRetry
];
1567 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][4];
1569 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxOk
[wFallBackRate
]++;
1571 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxFailures
++;
1573 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxRetry
+= byTxRetry
;
1574 if (byTxRetry
!= 0) {
1575 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxFail
[MAX_RATE
]+=byTxRetry
;
1576 if ( (byFallBack
== AUTO_FB_NONE
) ||
1577 (wRate
< RATE_18M
) ) {
1578 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxFail
[wRate
]+=byTxRetry
;
1579 } else if (byFallBack
== AUTO_FB_0
) {
1580 for(ii
=0;ii
<byTxRetry
;ii
++) {
1582 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][ii
];
1584 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][4];
1585 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxFail
[wFallBackRate
]++;
1587 } else if (byFallBack
== AUTO_FB_1
) {
1588 for(ii
=0;ii
<byTxRetry
;ii
++) {
1590 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][ii
];
1592 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][4];
1593 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxFail
[wFallBackRate
]++;
1610 * Routine Description:
1611 * Clear Nodes & skb in DB Table
1616 * hDeviceContext - The adapter context.
1617 * uStartIndex - starting index
1628 BSSvClearNodeDBTable(
1629 IN HANDLE hDeviceContext
,
1634 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1635 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
1636 struct sk_buff
*skb
;
1639 for (ii
= uStartIndex
; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
1640 if (pMgmt
->sNodeDBTable
[ii
].bActive
) {
1641 // check if sTxPSQueue has been initial
1642 if (pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
.next
!= NULL
) {
1643 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) != NULL
){
1644 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"PS skb != NULL %d\n", ii
);
1648 memset(&pMgmt
->sNodeDBTable
[ii
], 0, sizeof(KnownNodeDB
));
1656 VOID
s_vCheckSensitivity(
1657 IN HANDLE hDeviceContext
1660 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1661 PKnownBSS pBSSList
= NULL
;
1662 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
1665 if ((pDevice
->byLocalID
<= REV_ID_VT3253_A1
) && (pDevice
->byRFType
== RF_RFMD2959
) &&
1666 (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
)) {
1670 if ((pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) ||
1671 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))) {
1672 pBSSList
= BSSpAddrIsInBSSList(pDevice
, pMgmt
->abyCurrBSSID
, (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
);
1673 if (pBSSList
!= NULL
) {
1674 // Updata BB Reg if RSSI is too strong.
1675 LONG LocalldBmAverage
= 0;
1677 for (ii
= 0; ii
< RSSI_STAT_COUNT
; ii
++) {
1678 if (pBSSList
->ldBmAverage
[ii
] != 0) {
1680 LocalldBmAverage
+= pBSSList
->ldBmAverage
[ii
];
1683 if (uNumofdBm
> 0) {
1684 LocalldBmAverage
= LocalldBmAverage
/uNumofdBm
;
1685 for (ii
=0;ii
<BB_VGA_LEVEL
;ii
++) {
1686 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"LocalldBmAverage:%ld, %ld %02x\n", LocalldBmAverage
, pDevice
->ldBmThreshold
[ii
], pDevice
->abyBBVGA
[ii
]);
1687 if (LocalldBmAverage
< pDevice
->ldBmThreshold
[ii
]) {
1688 pDevice
->byBBVGANew
= pDevice
->abyBBVGA
[ii
];
1692 if (pDevice
->byBBVGANew
!= pDevice
->byBBVGACurrent
) {
1693 pDevice
->uBBVGADiffCount
++;
1694 if (pDevice
->uBBVGADiffCount
>= BB_VGA_CHANGE_THRESHOLD
)
1695 bScheduleCommand((HANDLE
) pDevice
, WLAN_CMD_CHANGE_BBSENSITIVITY
, NULL
);
1697 pDevice
->uBBVGADiffCount
= 0;
1706 BSSvClearAnyBSSJoinRecord (
1707 IN HANDLE hDeviceContext
1710 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1711 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
1714 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
1715 pMgmt
->sBSSList
[ii
].bSelected
= FALSE
;
1720 #ifdef Calcu_LinkQual
1721 VOID
s_uCalculateLinkQual(
1722 IN HANDLE hDeviceContext
1725 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1726 ULONG TxOkRatio
, TxCnt
;
1727 ULONG RxOkRatio
,RxCnt
;
1731 TxCnt
= pDevice
->scStatistic
.TxNoRetryOkCount
+
1732 pDevice
->scStatistic
.TxRetryOkCount
+
1733 pDevice
->scStatistic
.TxFailCount
;
1734 RxCnt
= pDevice
->scStatistic
.RxFcsErrCnt
+
1735 pDevice
->scStatistic
.RxOkCnt
;
1736 TxOkRatio
= (TxCnt
< 6) ? 4000:((pDevice
->scStatistic
.TxNoRetryOkCount
* 4000) / TxCnt
);
1737 RxOkRatio
= (RxCnt
< 6) ? 2000:((pDevice
->scStatistic
.RxOkCnt
* 2000) / RxCnt
);
1738 //decide link quality
1739 if(pDevice
->bLinkPass
!=TRUE
)
1741 // printk("s_uCalculateLinkQual-->Link disconnect and Poor quality**\n");
1742 pDevice
->scStatistic
.LinkQuality
= 0;
1743 pDevice
->scStatistic
.SignalStren
= 0;
1747 RFvRSSITodBm(pDevice
, (BYTE
)(pDevice
->uCurrRSSI
), &ldBm
);
1751 else if(-ldBm
> 90) {
1755 RssiRatio
= (40-(-ldBm
-50))*4000/40;
1757 pDevice
->scStatistic
.SignalStren
= RssiRatio
/40;
1758 pDevice
->scStatistic
.LinkQuality
= (RssiRatio
+TxOkRatio
+RxOkRatio
)/100;
1760 pDevice
->scStatistic
.RxFcsErrCnt
= 0;
1761 pDevice
->scStatistic
.RxOkCnt
= 0;
1762 pDevice
->scStatistic
.TxFailCount
= 0;
1763 pDevice
->scStatistic
.TxNoRetryOkCount
= 0;
1764 pDevice
->scStatistic
.TxRetryOkCount
= 0;
1769 VOID
s_vCheckPreEDThreshold(
1770 IN HANDLE hDeviceContext
1773 PSDevice pDevice
= (PSDevice
)hDeviceContext
;
1774 PKnownBSS pBSSList
= NULL
;
1775 PSMgmtObject pMgmt
= &(pDevice
->sMgmtObj
);
1777 if ((pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) ||
1778 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))) {
1779 pBSSList
= BSSpAddrIsInBSSList(pDevice
, pMgmt
->abyCurrBSSID
, (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
);
1780 if (pBSSList
!= NULL
) {
1781 pDevice
->byBBPreEDRSSI
= (BYTE
) (~(pBSSList
->ldBmAverRange
) + 1);
1782 //BBvUpdatePreEDThreshold(pDevice, FALSE);