On Tue, Nov 06, 2007 at 02:33:53AM -0800, akpm@linux-foundation.org wrote:
[mmotm.git] / drivers / staging / vt6656 / bssdb.c
blob6b1678bfd61a56749467f45eb53da020d58229e2
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
19 * File: bssdb.c
21 * Purpose: Handles the Basic Service Set & Node Database functions
23 * 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 * BSSbIsSTAInNodeDB - 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
34 * Revision History:
36 * Author: Lyndon Chen
38 * Date: July 17, 2002
42 #include "ttype.h"
43 #include "tmacro.h"
44 #include "tether.h"
45 #include "device.h"
46 #include "80211hdr.h"
47 #include "bssdb.h"
48 #include "wmgr.h"
49 #include "datarate.h"
50 #include "desc.h"
51 #include "wcmd.h"
52 #include "wpa.h"
53 #include "baseband.h"
54 #include "rf.h"
55 #include "card.h"
56 #include "mac.h"
57 #include "wpa2.h"
58 #include "control.h"
59 #include "rndis.h"
60 #include "iowpa.h"
62 /*--------------------- Static Definitions -------------------------*/
67 /*--------------------- Static Classes ----------------------------*/
69 /*--------------------- Static Variables --------------------------*/
70 static int msglevel =MSG_LEVEL_INFO;
71 //static int msglevel =MSG_LEVEL_DEBUG;
75 const WORD awHWRetry0[5][5] = {
76 {RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M},
77 {RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M},
78 {RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M},
79 {RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M},
80 {RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M}
82 const WORD awHWRetry1[5][5] = {
83 {RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M},
84 {RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M},
85 {RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M},
86 {RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M},
87 {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
92 /*--------------------- Static Functions --------------------------*/
94 VOID s_vCheckSensitivity(
95 IN HANDLE hDeviceContext
98 VOID s_vCheckPreEDThreshold(
99 IN HANDLE hDeviceContext
102 #ifdef Calcu_LinkQual
103 VOID s_uCalculateLinkQual(
104 IN HANDLE hDeviceContext
106 #endif
107 /*--------------------- Export Variables --------------------------*/
110 /*--------------------- Export Functions --------------------------*/
118 * Routine Description:
119 * Search known BSS list for Desire SSID or BSSID.
121 * Return Value:
122 * PTR to KnownBSS or NULL
126 PKnownBSS
127 BSSpSearchBSSList(
128 IN HANDLE hDeviceContext,
129 IN PBYTE pbyDesireBSSID,
130 IN PBYTE pbyDesireSSID,
131 IN CARD_PHY_TYPE ePhyType
134 PSDevice pDevice = (PSDevice)hDeviceContext;
135 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
136 PBYTE pbyBSSID = NULL;
137 PWLAN_IE_SSID pSSID = NULL;
138 PKnownBSS pCurrBSS = NULL;
139 PKnownBSS pSelect = NULL;
140 BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
141 UINT ii = 0;
142 UINT jj = 0; //DavidWang
143 if (pbyDesireBSSID != NULL) {
144 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList BSSID[%02X %02X %02X-%02X %02X %02X]\n",
145 *pbyDesireBSSID,*(pbyDesireBSSID+1),*(pbyDesireBSSID+2),
146 *(pbyDesireBSSID+3),*(pbyDesireBSSID+4),*(pbyDesireBSSID+5));
147 if ((!IS_BROADCAST_ADDRESS(pbyDesireBSSID)) &&
148 (memcmp(pbyDesireBSSID, ZeroBSSID, 6)!= 0)){
149 pbyBSSID = pbyDesireBSSID;
152 if (pbyDesireSSID != NULL) {
153 if (((PWLAN_IE_SSID)pbyDesireSSID)->len != 0) {
154 pSSID = (PWLAN_IE_SSID) pbyDesireSSID;
158 if ((pbyBSSID != NULL)&&(pDevice->bRoaming == FALSE)) {
159 // match BSSID first
160 for (ii = 0; ii <MAX_BSS_NUM; ii++) {
161 pCurrBSS = &(pMgmt->sBSSList[ii]);
163 //2008-0718-01<Add>by MikeLiu
164 pCurrBSS->bSelected = FALSE;
166 if ((pCurrBSS->bActive) &&
167 (pCurrBSS->bSelected == FALSE)) {
168 if (IS_ETH_ADDRESS_EQUAL(pCurrBSS->abyBSSID, pbyBSSID)) {
169 if (pSSID != NULL) {
170 // compare ssid
171 if ( !memcmp(pSSID->abySSID,
172 ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID,
173 pSSID->len)) {
174 if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
175 ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
176 ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo))
178 pCurrBSS->bSelected = TRUE;
179 return(pCurrBSS);
182 } else {
183 if ((pMgmt->eConfigMode == WMAC_CONFIG_AUTO) ||
184 ((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo)) ||
185 ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo))
187 pCurrBSS->bSelected = TRUE;
188 return(pCurrBSS);
194 } else {
195 // ignore BSSID
196 for (ii = 0; ii <MAX_BSS_NUM; ii++) {
197 pCurrBSS = &(pMgmt->sBSSList[ii]);
199 //2007-0721-01<Mark>by MikeLiu
200 // if ((pCurrBSS->bActive) &&
201 // (pCurrBSS->bSelected == FALSE)) {
203 //2007-0721-01<Add>by MikeLiu
204 pCurrBSS->bSelected = FALSE;
205 if (pCurrBSS->bActive) {
207 if (pSSID != NULL) {
208 // matched SSID
209 if (memcmp(pSSID->abySSID,
210 ((PWLAN_IE_SSID)pCurrBSS->abySSID)->abySSID,
211 pSSID->len) ||
212 (pSSID->len != ((PWLAN_IE_SSID)pCurrBSS->abySSID)->len)) {
213 // SSID not match skip this BSS
214 continue;
217 if (((pMgmt->eConfigMode == WMAC_CONFIG_IBSS_STA) && WLAN_GET_CAP_INFO_ESS(pCurrBSS->wCapInfo)) ||
218 ((pMgmt->eConfigMode == WMAC_CONFIG_ESS_STA) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS->wCapInfo))
220 // Type not match skip this BSS
221 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSS type mismatch.... Config[%d] BSS[0x%04x]\n", pMgmt->eConfigMode, pCurrBSS->wCapInfo);
222 continue;
225 if (ePhyType != PHY_TYPE_AUTO) {
226 if (((ePhyType == PHY_TYPE_11A) && (PHY_TYPE_11A != pCurrBSS->eNetworkTypeInUse)) ||
227 ((ePhyType != PHY_TYPE_11A) && (PHY_TYPE_11A == pCurrBSS->eNetworkTypeInUse))) {
228 // PhyType not match skip this BSS
229 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Physical type mismatch.... ePhyType[%d] BSS[%d]\n", ePhyType, pCurrBSS->eNetworkTypeInUse);
230 continue;
234 if (pMgmt->eAuthenMode < WMAC_AUTH_WPA) {
235 if (pCurrBSS->bWPAValid == TRUE) {
236 // WPA AP will reject connection of station without WPA enable.
237 continue;
239 } else if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
240 (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK)) {
241 if (pCurrBSS->bWPAValid == FALSE) {
242 // station with WPA enable can't join NonWPA AP.
243 continue;
245 } else if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
246 (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
247 if (pCurrBSS->bWPA2Valid == FALSE) {
248 // station with WPA2 enable can't join NonWPA2 AP.
249 continue;
253 //DavidWang
254 pMgmt->pSameBSS[jj].uChannel = pCurrBSS->uChannel;
255 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList pSelect1[%02X %02X %02X-%02X %02X %02X]\n",*pCurrBSS->abyBSSID,*(pCurrBSS->abyBSSID+1),*(pCurrBSS->abyBSSID+2),*(pCurrBSS->abyBSSID+3),*(pCurrBSS->abyBSSID+4),*(pCurrBSS->abyBSSID+5));
256 jj++;
258 //DavidWang
259 if (pSelect == NULL) {
260 pSelect = pCurrBSS;
261 } else {
262 // compare RSSI, select signal strong one
263 if (pCurrBSS->uRSSI < pSelect->uRSSI) {
264 pSelect = pCurrBSS;
269 //DavidWang
270 pDevice->bSameBSSMaxNum = jj;
271 //DavidWang
272 if (pSelect != NULL) {
273 pSelect->bSelected = TRUE;
274 if (pDevice->bRoaming == FALSE) {
275 // Einsn Add @20070907
276 memset(pbyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
277 memcpy(pbyDesireSSID,pCurrBSS->abySSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1) ;
280 return(pSelect);
283 return(NULL);
290 * Routine Description:
291 * Clear BSS List
293 * Return Value:
294 * None.
299 VOID
300 BSSvClearBSSList(
301 IN HANDLE hDeviceContext,
302 IN BOOL bKeepCurrBSSID
305 PSDevice pDevice = (PSDevice)hDeviceContext;
306 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
307 UINT ii;
309 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
310 if (bKeepCurrBSSID) {
311 if (pMgmt->sBSSList[ii].bActive &&
312 IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pMgmt->abyCurrBSSID)) {
313 //mike mark: there are two same BSSID in list if that AP is in hidden ssid mode,one 's SSID is null,
314 // but other's is obvious, so if it acssociate with your STA exactly,you must keep two
315 // of them!!!!!!!!!
316 // bKeepCurrBSSID = FALSE;
317 continue;
321 if ((pMgmt->sBSSList[ii].bActive) && (pMgmt->sBSSList[ii].uClearCount < BSS_CLEAR_COUNT)) {
322 pMgmt->sBSSList[ii].uClearCount ++;
323 continue;
326 pMgmt->sBSSList[ii].bActive = FALSE;
327 memset(&pMgmt->sBSSList[ii], 0, sizeof(KnownBSS));
329 BSSvClearAnyBSSJoinRecord(pDevice);
331 return;
338 * Routine Description:
339 * search BSS list by BSSID & SSID if matched
341 * Return Value:
342 * TRUE if found.
345 PKnownBSS
346 BSSpAddrIsInBSSList(
347 IN HANDLE hDeviceContext,
348 IN PBYTE abyBSSID,
349 IN PWLAN_IE_SSID pSSID
352 PSDevice pDevice = (PSDevice)hDeviceContext;
353 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
354 PKnownBSS pBSSList = NULL;
355 UINT ii;
357 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
358 pBSSList = &(pMgmt->sBSSList[ii]);
359 if (pBSSList->bActive) {
360 if (IS_ETH_ADDRESS_EQUAL(pBSSList->abyBSSID, abyBSSID)) {
361 if (pSSID->len == ((PWLAN_IE_SSID)pBSSList->abySSID)->len){
362 if (memcmp(pSSID->abySSID,
363 ((PWLAN_IE_SSID)pBSSList->abySSID)->abySSID,
364 pSSID->len) == 0)
365 return pBSSList;
371 return NULL;
378 * Routine Description:
379 * Insert a BSS set into known BSS list
381 * Return Value:
382 * TRUE if success.
386 BOOL
387 BSSbInsertToBSSList (
388 IN HANDLE hDeviceContext,
389 IN PBYTE abyBSSIDAddr,
390 IN QWORD qwTimestamp,
391 IN WORD wBeaconInterval,
392 IN WORD wCapInfo,
393 IN BYTE byCurrChannel,
394 IN PWLAN_IE_SSID pSSID,
395 IN PWLAN_IE_SUPP_RATES pSuppRates,
396 IN PWLAN_IE_SUPP_RATES pExtSuppRates,
397 IN PERPObject psERP,
398 IN PWLAN_IE_RSN pRSN,
399 IN PWLAN_IE_RSN_EXT pRSNWPA,
400 IN PWLAN_IE_COUNTRY pIE_Country,
401 IN PWLAN_IE_QUIET pIE_Quiet,
402 IN UINT uIELength,
403 IN PBYTE pbyIEs,
404 IN HANDLE pRxPacketContext
408 PSDevice pDevice = (PSDevice)hDeviceContext;
409 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
410 PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
411 PKnownBSS pBSSList = NULL;
412 UINT ii;
413 BOOL bParsingQuiet = FALSE;
417 pBSSList = (PKnownBSS)&(pMgmt->sBSSList[0]);
419 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
420 pBSSList = (PKnownBSS)&(pMgmt->sBSSList[ii]);
421 if (!pBSSList->bActive)
422 break;
425 if (ii == MAX_BSS_NUM){
426 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Get free KnowBSS node failed.\n");
427 return FALSE;
429 // save the BSS info
430 pBSSList->bActive = TRUE;
431 memcpy( pBSSList->abyBSSID, abyBSSIDAddr, WLAN_BSSID_LEN);
432 HIDWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(HIDWORD(qwTimestamp));
433 LODWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(LODWORD(qwTimestamp));
434 pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval);
435 pBSSList->wCapInfo = cpu_to_le16(wCapInfo);
436 pBSSList->uClearCount = 0;
438 if (pSSID->len > WLAN_SSID_MAXLEN)
439 pSSID->len = WLAN_SSID_MAXLEN;
440 memcpy( pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
442 pBSSList->uChannel = byCurrChannel;
444 if (pSuppRates->len > WLAN_RATES_MAXLEN)
445 pSuppRates->len = WLAN_RATES_MAXLEN;
446 memcpy( pBSSList->abySuppRates, pSuppRates, pSuppRates->len + WLAN_IEHDR_LEN);
448 if (pExtSuppRates != NULL) {
449 if (pExtSuppRates->len > WLAN_RATES_MAXLEN)
450 pExtSuppRates->len = WLAN_RATES_MAXLEN;
451 memcpy(pBSSList->abyExtSuppRates, pExtSuppRates, pExtSuppRates->len + WLAN_IEHDR_LEN);
452 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSbInsertToBSSList: pExtSuppRates->len = %d\n", pExtSuppRates->len);
454 } else {
455 memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
457 pBSSList->sERP.byERP = psERP->byERP;
458 pBSSList->sERP.bERPExist = psERP->bERPExist;
460 // Check if BSS is 802.11a/b/g
461 if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) {
462 pBSSList->eNetworkTypeInUse = PHY_TYPE_11A;
463 } else {
464 if (pBSSList->sERP.bERPExist == TRUE) {
465 pBSSList->eNetworkTypeInUse = PHY_TYPE_11G;
466 } else {
467 pBSSList->eNetworkTypeInUse = PHY_TYPE_11B;
471 pBSSList->byRxRate = pRxPacket->byRxRate;
472 pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF;
473 pBSSList->uRSSI = pRxPacket->uRSSI;
474 pBSSList->bySQ = pRxPacket->bySQ;
476 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
477 (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
478 // assoc with BSS
479 if (pBSSList == pMgmt->pCurrBSS) {
480 bParsingQuiet = TRUE;
484 WPA_ClearRSN(pBSSList);
486 if (pRSNWPA != NULL) {
487 UINT uLen = pRSNWPA->len + 2;
489 if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) {
490 pBSSList->wWPALen = uLen;
491 memcpy(pBSSList->byWPAIE, pRSNWPA, uLen);
492 WPA_ParseRSN(pBSSList, pRSNWPA);
496 WPA2_ClearRSN(pBSSList);
498 if (pRSN != NULL) {
499 UINT uLen = pRSN->len + 2;
500 if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) {
501 pBSSList->wRSNLen = uLen;
502 memcpy(pBSSList->byRSNIE, pRSN, uLen);
503 WPA2vParseRSN(pBSSList, pRSN);
507 if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pBSSList->bWPA2Valid == TRUE)) {
509 PSKeyItem pTransmitKey = NULL;
510 BOOL bIs802_1x = FALSE;
512 for (ii = 0; ii < pBSSList->wAKMSSAuthCount; ii ++) {
513 if (pBSSList->abyAKMSSAuthType[ii] == WLAN_11i_AKMSS_802_1X) {
514 bIs802_1x = TRUE;
515 break;
518 if ((bIs802_1x == TRUE) && (pSSID->len == ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->len) &&
519 ( !memcmp(pSSID->abySSID, ((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySSID, pSSID->len))) {
521 bAdd_PMKID_Candidate((HANDLE)pDevice, pBSSList->abyBSSID, &pBSSList->sRSNCapObj);
523 if ((pDevice->bLinkPass == TRUE) && (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
524 if ((KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, PAIRWISE_KEY, &pTransmitKey) == TRUE) ||
525 (KeybGetTransmitKey(&(pDevice->sKey), pDevice->abyBSSID, GROUP_KEY, &pTransmitKey) == TRUE)) {
526 pDevice->gsPMKIDCandidate.StatusType = Ndis802_11StatusType_PMKID_CandidateList;
527 pDevice->gsPMKIDCandidate.Version = 1;
535 if (pDevice->bUpdateBBVGA) {
536 // Moniter if RSSI is too strong.
537 pBSSList->byRSSIStatCnt = 0;
538 RFvRSSITodBm(pDevice, (BYTE)(pRxPacket->uRSSI), &pBSSList->ldBmMAX);
539 pBSSList->ldBmAverage[0] = pBSSList->ldBmMAX;
540 pBSSList->ldBmAverRange = pBSSList->ldBmMAX;
541 for (ii = 1; ii < RSSI_STAT_COUNT; ii++)
542 pBSSList->ldBmAverage[ii] = 0;
546 if ((pIE_Country != NULL) &&
547 (pMgmt->b11hEnable == TRUE)) {
548 CARDvSetCountryInfo(pMgmt->pAdapter,
549 pBSSList->eNetworkTypeInUse,
550 pIE_Country);
553 if ((bParsingQuiet == TRUE) && (pIE_Quiet != NULL)) {
554 if ((((PWLAN_IE_QUIET)pIE_Quiet)->len == 8) &&
555 (((PWLAN_IE_QUIET)pIE_Quiet)->byQuietCount != 0)) {
556 // valid EID
557 if (pQuiet == NULL) {
558 pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
559 CARDbSetQuiet( pMgmt->pAdapter,
560 TRUE,
561 pQuiet->byQuietCount,
562 pQuiet->byQuietPeriod,
563 *((PWORD)pQuiet->abyQuietDuration),
564 *((PWORD)pQuiet->abyQuietOffset)
566 } else {
567 pQuiet = (PWLAN_IE_QUIET)pIE_Quiet;
568 CARDbSetQuiet( pMgmt->pAdapter,
569 FALSE,
570 pQuiet->byQuietCount,
571 pQuiet->byQuietPeriod,
572 *((PWORD)pQuiet->abyQuietDuration),
573 *((PWORD)pQuiet->abyQuietOffset)
579 if ((bParsingQuiet == TRUE) &&
580 (pQuiet != NULL)) {
581 CARDbStartQuiet(pMgmt->pAdapter);
585 pBSSList->uIELength = uIELength;
586 if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN)
587 pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN;
588 memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength);
590 return TRUE;
596 * Routine Description:
597 * Update BSS set in known BSS list
599 * Return Value:
600 * TRUE if success.
603 // TODO: input structure modify
605 BOOL
606 BSSbUpdateToBSSList (
607 IN HANDLE hDeviceContext,
608 IN QWORD qwTimestamp,
609 IN WORD wBeaconInterval,
610 IN WORD wCapInfo,
611 IN BYTE byCurrChannel,
612 IN BOOL bChannelHit,
613 IN PWLAN_IE_SSID pSSID,
614 IN PWLAN_IE_SUPP_RATES pSuppRates,
615 IN PWLAN_IE_SUPP_RATES pExtSuppRates,
616 IN PERPObject psERP,
617 IN PWLAN_IE_RSN pRSN,
618 IN PWLAN_IE_RSN_EXT pRSNWPA,
619 IN PWLAN_IE_COUNTRY pIE_Country,
620 IN PWLAN_IE_QUIET pIE_Quiet,
621 IN PKnownBSS pBSSList,
622 IN UINT uIELength,
623 IN PBYTE pbyIEs,
624 IN HANDLE pRxPacketContext
627 int ii, jj;
628 PSDevice pDevice = (PSDevice)hDeviceContext;
629 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
630 PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
631 LONG ldBm, ldBmSum;
632 BOOL bParsingQuiet = FALSE;
633 // BYTE abyTmpSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
636 if (pBSSList == NULL)
637 return FALSE;
640 HIDWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(HIDWORD(qwTimestamp));
641 LODWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(LODWORD(qwTimestamp));
642 pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval);
643 pBSSList->wCapInfo = cpu_to_le16(wCapInfo);
644 pBSSList->uClearCount = 0;
645 pBSSList->uChannel = byCurrChannel;
646 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSbUpdateToBSSList: pBSSList->uChannel: %d\n", pBSSList->uChannel);
648 if (pSSID->len > WLAN_SSID_MAXLEN)
649 pSSID->len = WLAN_SSID_MAXLEN;
651 if ((pSSID->len != 0) && (pSSID->abySSID[0] != 0))
652 memcpy(pBSSList->abySSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
653 memcpy(pBSSList->abySuppRates, pSuppRates,pSuppRates->len + WLAN_IEHDR_LEN);
655 if (pExtSuppRates != NULL) {
656 memcpy(pBSSList->abyExtSuppRates, pExtSuppRates,pExtSuppRates->len + WLAN_IEHDR_LEN);
657 } else {
658 memset(pBSSList->abyExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1);
660 pBSSList->sERP.byERP = psERP->byERP;
661 pBSSList->sERP.bERPExist = psERP->bERPExist;
663 // Check if BSS is 802.11a/b/g
664 if (pBSSList->uChannel > CB_MAX_CHANNEL_24G) {
665 pBSSList->eNetworkTypeInUse = PHY_TYPE_11A;
666 } else {
667 if (pBSSList->sERP.bERPExist == TRUE) {
668 pBSSList->eNetworkTypeInUse = PHY_TYPE_11G;
669 } else {
670 pBSSList->eNetworkTypeInUse = PHY_TYPE_11B;
674 pBSSList->byRxRate = pRxPacket->byRxRate;
675 pBSSList->qwLocalTSF = pRxPacket->qwLocalTSF;
676 if(bChannelHit)
677 pBSSList->uRSSI = pRxPacket->uRSSI;
678 pBSSList->bySQ = pRxPacket->bySQ;
680 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
681 (pMgmt->eCurrState == WMAC_STATE_ASSOC)) {
682 // assoc with BSS
683 if (pBSSList == pMgmt->pCurrBSS) {
684 bParsingQuiet = TRUE;
688 WPA_ClearRSN(pBSSList); //mike update
690 if (pRSNWPA != NULL) {
691 UINT uLen = pRSNWPA->len + 2;
692 if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) {
693 pBSSList->wWPALen = uLen;
694 memcpy(pBSSList->byWPAIE, pRSNWPA, uLen);
695 WPA_ParseRSN(pBSSList, pRSNWPA);
699 WPA2_ClearRSN(pBSSList); //mike update
701 if (pRSN != NULL) {
702 UINT uLen = pRSN->len + 2;
703 if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) {
704 pBSSList->wRSNLen = uLen;
705 memcpy(pBSSList->byRSNIE, pRSN, uLen);
706 WPA2vParseRSN(pBSSList, pRSN);
710 if (pRxPacket->uRSSI != 0) {
711 RFvRSSITodBm(pDevice, (BYTE)(pRxPacket->uRSSI), &ldBm);
712 // Moniter if RSSI is too strong.
713 pBSSList->byRSSIStatCnt++;
714 pBSSList->byRSSIStatCnt %= RSSI_STAT_COUNT;
715 pBSSList->ldBmAverage[pBSSList->byRSSIStatCnt] = ldBm;
716 ldBmSum = 0;
717 for(ii=0, jj=0;ii<RSSI_STAT_COUNT;ii++) {
718 if (pBSSList->ldBmAverage[ii] != 0) {
719 pBSSList->ldBmMAX = max(pBSSList->ldBmAverage[ii], ldBm);
720 ldBmSum += pBSSList->ldBmAverage[ii];
721 jj++;
724 pBSSList->ldBmAverRange = ldBmSum /jj;
727 pBSSList->uIELength = uIELength;
728 if (pBSSList->uIELength > WLAN_BEACON_FR_MAXLEN)
729 pBSSList->uIELength = WLAN_BEACON_FR_MAXLEN;
730 memcpy(pBSSList->abyIEs, pbyIEs, pBSSList->uIELength);
732 //mike add: if the AP in this pBSSList is hidden ssid and we can find two of them,
733 // you need upgrade the other related pBSSList of which ssid is obvious,
734 // for these two AP is the same one!!!!
735 /********judge by:BSSID is the same,but ssid is different!*****************/
736 #if 0
737 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
738 if (IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pBSSList->abyBSSID)) { //BSSID is the same!
739 if (memcmp(((PWLAN_IE_SSID)pMgmt->sBSSList[ii].abySSID)->abySSID, //ssid is different??
740 ((PWLAN_IE_SSID)pBSSList->abySSID)->abySSID,
741 ((PWLAN_IE_SSID)pBSSList->abySSID)->len) != 0) {
742 //reserve temp
743 memset(abyTmpSSID,0,sizeof(abyTmpSSID));
744 memcpy(abyTmpSSID,pMgmt->sBSSList[ii].abySSID,sizeof(abyTmpSSID));
745 //upgrade the other one pBSSList
746 memcpy(&(pMgmt->sBSSList[ii]),pBSSList,sizeof(KnownBSS));
747 //recover ssid info
748 memcpy(pMgmt->sBSSList[ii].abySSID,abyTmpSSID,sizeof(abyTmpSSID));
752 #endif
754 return TRUE;
763 * Routine Description:
764 * Search Node DB table to find the index of matched DstAddr
766 * Return Value:
767 * None
771 BOOL
772 BSSbIsSTAInNodeDB(
773 IN HANDLE hDeviceContext,
774 IN PBYTE abyDstAddr,
775 OUT PUINT puNodeIndex
778 PSDevice pDevice = (PSDevice)hDeviceContext;
779 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
780 UINT ii;
782 // Index = 0 reserved for AP Node
783 for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
784 if (pMgmt->sNodeDBTable[ii].bActive) {
785 if (IS_ETH_ADDRESS_EQUAL(abyDstAddr, pMgmt->sNodeDBTable[ii].abyMACAddr)) {
786 *puNodeIndex = ii;
787 return TRUE;
792 return FALSE;
799 * Routine Description:
800 * Find an empty node and allocated; if no empty found,
801 * instand used of most inactive one.
803 * Return Value:
804 * None
807 VOID
808 BSSvCreateOneNode(
809 IN HANDLE hDeviceContext,
810 OUT PUINT puNodeIndex
814 PSDevice pDevice = (PSDevice)hDeviceContext;
815 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
816 UINT ii;
817 UINT BigestCount = 0;
818 UINT SelectIndex;
819 struct sk_buff *skb;
820 // Index = 0 reserved for AP Node (In STA mode)
821 // Index = 0 reserved for Broadcast/MultiCast (In AP mode)
822 SelectIndex = 1;
823 for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
824 if (pMgmt->sNodeDBTable[ii].bActive) {
825 if (pMgmt->sNodeDBTable[ii].uInActiveCount > BigestCount) {
826 BigestCount = pMgmt->sNodeDBTable[ii].uInActiveCount;
827 SelectIndex = ii;
830 else {
831 break;
835 // if not found replace uInActiveCount is largest one.
836 if ( ii == (MAX_NODE_NUM + 1)) {
837 *puNodeIndex = SelectIndex;
838 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Replace inactive node = %d\n", SelectIndex);
839 // clear ps buffer
840 if (pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue.next != NULL) {
841 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue)) != NULL)
842 dev_kfree_skb(skb);
845 else {
846 *puNodeIndex = ii;
849 memset(&pMgmt->sNodeDBTable[*puNodeIndex], 0, sizeof(KnownNodeDB));
850 pMgmt->sNodeDBTable[*puNodeIndex].bActive = TRUE;
851 pMgmt->sNodeDBTable[*puNodeIndex].uRatePollTimeout = FALLBACK_POLL_SECOND;
852 // for AP mode PS queue
853 skb_queue_head_init(&pMgmt->sNodeDBTable[*puNodeIndex].sTxPSQueue);
854 pMgmt->sNodeDBTable[*puNodeIndex].byAuthSequence = 0;
855 pMgmt->sNodeDBTable[*puNodeIndex].wEnQueueCnt = 0;
856 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Create node index = %d\n", ii);
857 return;
864 * Routine Description:
865 * Remove Node by NodeIndex
868 * Return Value:
869 * None
872 VOID
873 BSSvRemoveOneNode(
874 IN HANDLE hDeviceContext,
875 IN UINT uNodeIndex
879 PSDevice pDevice = (PSDevice)hDeviceContext;
880 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
881 BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
882 struct sk_buff *skb;
885 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue)) != NULL)
886 dev_kfree_skb(skb);
887 // clear context
888 memset(&pMgmt->sNodeDBTable[uNodeIndex], 0, sizeof(KnownNodeDB));
889 // clear tx bit map
890 pMgmt->abyPSTxMap[pMgmt->sNodeDBTable[uNodeIndex].wAID >> 3] &= ~byMask[pMgmt->sNodeDBTable[uNodeIndex].wAID & 7];
892 return;
896 * Routine Description:
897 * Update AP Node content in Index 0 of KnownNodeDB
900 * Return Value:
901 * None
905 VOID
906 BSSvUpdateAPNode(
907 IN HANDLE hDeviceContext,
908 IN PWORD pwCapInfo,
909 IN PWLAN_IE_SUPP_RATES pSuppRates,
910 IN PWLAN_IE_SUPP_RATES pExtSuppRates
913 PSDevice pDevice = (PSDevice)hDeviceContext;
914 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
915 UINT uRateLen = WLAN_RATES_MAXLEN;
917 memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
919 pMgmt->sNodeDBTable[0].bActive = TRUE;
920 if (pDevice->byBBType == BB_TYPE_11B) {
921 uRateLen = WLAN_RATES_MAXLEN_11B;
923 pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pSuppRates,
924 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
925 uRateLen);
926 pMgmt->abyCurrExtSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)pExtSuppRates,
927 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
928 uRateLen);
929 RATEvParseMaxRate((PVOID) pDevice,
930 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
931 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
932 TRUE,
933 &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
934 &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
935 &(pMgmt->sNodeDBTable[0].wSuppRate),
936 &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
937 &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
939 memcpy(pMgmt->sNodeDBTable[0].abyMACAddr, pMgmt->abyCurrBSSID, WLAN_ADDR_LEN);
940 pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxSuppRate;
941 pMgmt->sNodeDBTable[0].bShortPreamble = WLAN_GET_CAP_INFO_SHORTPREAMBLE(*pwCapInfo);
942 pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND;
943 // Auto rate fallback function initiation.
944 // RATEbInit(pDevice);
945 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pMgmt->sNodeDBTable[0].wTxDataRate = %d \n", pMgmt->sNodeDBTable[0].wTxDataRate);
955 * Routine Description:
956 * Add Multicast Node content in Index 0 of KnownNodeDB
959 * Return Value:
960 * None
965 VOID
966 BSSvAddMulticastNode(
967 IN HANDLE hDeviceContext
970 PSDevice pDevice = (PSDevice)hDeviceContext;
971 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
973 if (!pDevice->bEnableHostWEP)
974 memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
975 memset(pMgmt->sNodeDBTable[0].abyMACAddr, 0xff, WLAN_ADDR_LEN);
976 pMgmt->sNodeDBTable[0].bActive = TRUE;
977 pMgmt->sNodeDBTable[0].bPSEnable = FALSE;
978 skb_queue_head_init(&pMgmt->sNodeDBTable[0].sTxPSQueue);
979 RATEvParseMaxRate((PVOID) pDevice,
980 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
981 (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates,
982 TRUE,
983 &(pMgmt->sNodeDBTable[0].wMaxBasicRate),
984 &(pMgmt->sNodeDBTable[0].wMaxSuppRate),
985 &(pMgmt->sNodeDBTable[0].wSuppRate),
986 &(pMgmt->sNodeDBTable[0].byTopCCKBasicRate),
987 &(pMgmt->sNodeDBTable[0].byTopOFDMBasicRate)
989 pMgmt->sNodeDBTable[0].wTxDataRate = pMgmt->sNodeDBTable[0].wMaxBasicRate;
990 pMgmt->sNodeDBTable[0].uRatePollTimeout = FALLBACK_POLL_SECOND;
1000 * Routine Description:
1003 * Second call back function to update Node DB info & AP link status
1006 * Return Value:
1007 * none.
1012 VOID
1013 BSSvSecondCallBack(
1014 IN HANDLE hDeviceContext
1017 PSDevice pDevice = (PSDevice)hDeviceContext;
1018 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1019 UINT ii;
1020 PWLAN_IE_SSID pItemSSID, pCurrSSID;
1021 UINT uSleepySTACnt = 0;
1022 UINT uNonShortSlotSTACnt = 0;
1023 UINT uLongPreambleSTACnt = 0;
1024 viawget_wpa_header *wpahdr; //DavidWang
1026 spin_lock_irq(&pDevice->lock);
1028 pDevice->uAssocCount = 0;
1030 //Power Saving Mode Tx Burst
1031 if ( pDevice->bEnablePSMode == TRUE ) {
1032 pDevice->ulPSModeWaitTx++;
1033 if ( pDevice->ulPSModeWaitTx >= 2 ) {
1034 pDevice->ulPSModeWaitTx = 0;
1035 pDevice->bPSModeTxBurst = FALSE;
1039 pDevice->byERPFlag &=
1040 ~(WLAN_SET_ERP_BARKER_MODE(1) | WLAN_SET_ERP_NONERP_PRESENT(1));
1042 if (pDevice->wUseProtectCntDown > 0) {
1043 pDevice->wUseProtectCntDown --;
1045 else {
1046 // disable protect mode
1047 pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1));
1050 if(pDevice->byReAssocCount > 0) {
1051 pDevice->byReAssocCount++;
1052 if((pDevice->byReAssocCount > 10) && (pDevice->bLinkPass != TRUE)) { //10 sec timeout
1053 printk("Re-association timeout!!!\n");
1054 pDevice->byReAssocCount = 0;
1055 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1056 // if(pDevice->bWPASuppWextEnabled == TRUE)
1058 union iwreq_data wrqu;
1059 memset(&wrqu, 0, sizeof (wrqu));
1060 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1061 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
1062 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
1064 #endif
1066 else if(pDevice->bLinkPass == TRUE)
1067 pDevice->byReAssocCount = 0;
1070 #ifdef SndEvt_ToAPI
1071 if((pMgmt->eCurrState!=WMAC_STATE_ASSOC) &&
1072 (pMgmt->eLastState==WMAC_STATE_ASSOC))
1074 union iwreq_data wrqu;
1075 memset(&wrqu, 0, sizeof(wrqu));
1076 wrqu.data.flags = RT_DISCONNECTED_EVENT_FLAG;
1077 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, NULL);
1079 pMgmt->eLastState = pMgmt->eCurrState ;
1080 #endif
1082 #ifdef Calcu_LinkQual
1083 s_uCalculateLinkQual((HANDLE)pDevice);
1084 #endif
1086 for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
1088 if (pMgmt->sNodeDBTable[ii].bActive) {
1089 // Increase in-activity counter
1090 pMgmt->sNodeDBTable[ii].uInActiveCount++;
1092 if (ii > 0) {
1093 if (pMgmt->sNodeDBTable[ii].uInActiveCount > MAX_INACTIVE_COUNT) {
1094 BSSvRemoveOneNode(pDevice, ii);
1095 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
1096 "Inactive timeout [%d] sec, STA index = [%d] remove\n", MAX_INACTIVE_COUNT, ii);
1097 continue;
1100 if (pMgmt->sNodeDBTable[ii].eNodeState >= NODE_ASSOC) {
1102 pDevice->uAssocCount++;
1104 // check if Non ERP exist
1105 if (pMgmt->sNodeDBTable[ii].uInActiveCount < ERP_RECOVER_COUNT) {
1106 if (!pMgmt->sNodeDBTable[ii].bShortPreamble) {
1107 pDevice->byERPFlag |= WLAN_SET_ERP_BARKER_MODE(1);
1108 uLongPreambleSTACnt ++;
1110 if (!pMgmt->sNodeDBTable[ii].bERPExist) {
1111 pDevice->byERPFlag |= WLAN_SET_ERP_NONERP_PRESENT(1);
1112 pDevice->byERPFlag |= WLAN_SET_ERP_USE_PROTECTION(1);
1114 if (!pMgmt->sNodeDBTable[ii].bShortSlotTime)
1115 uNonShortSlotSTACnt++;
1119 // check if any STA in PS mode
1120 if (pMgmt->sNodeDBTable[ii].bPSEnable)
1121 uSleepySTACnt++;
1126 // Rate fallback check
1127 if (!pDevice->bFixRate) {
1129 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) && (ii == 0))
1130 RATEvTxRateFallBack(pDevice, &(pMgmt->sNodeDBTable[ii]));
1132 if (ii > 0) {
1133 // ii = 0 for multicast node (AP & Adhoc)
1134 RATEvTxRateFallBack((PVOID)pDevice, &(pMgmt->sNodeDBTable[ii]));
1136 else {
1137 // ii = 0 reserved for unicast AP node (Infra STA)
1138 if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)
1139 RATEvTxRateFallBack((PVOID)pDevice, &(pMgmt->sNodeDBTable[ii]));
1144 // check if pending PS queue
1145 if (pMgmt->sNodeDBTable[ii].wEnQueueCnt != 0) {
1146 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Index= %d, Queue = %d pending \n",
1147 ii, pMgmt->sNodeDBTable[ii].wEnQueueCnt);
1148 if ((ii >0) && (pMgmt->sNodeDBTable[ii].wEnQueueCnt > 15)) {
1149 BSSvRemoveOneNode(pDevice, ii);
1150 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Pending many queues PS STA Index = %d remove \n", ii);
1151 continue;
1159 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->byBBType == BB_TYPE_11G)) {
1161 // on/off protect mode
1162 if (WLAN_GET_ERP_USE_PROTECTION(pDevice->byERPFlag)) {
1163 if (!pDevice->bProtectMode) {
1164 MACvEnableProtectMD(pDevice);
1165 pDevice->bProtectMode = TRUE;
1168 else {
1169 if (pDevice->bProtectMode) {
1170 MACvDisableProtectMD(pDevice);
1171 pDevice->bProtectMode = FALSE;
1174 // on/off short slot time
1176 if (uNonShortSlotSTACnt > 0) {
1177 if (pDevice->bShortSlotTime) {
1178 pDevice->bShortSlotTime = FALSE;
1179 BBvSetShortSlotTime(pDevice);
1180 vUpdateIFS((PVOID)pDevice);
1183 else {
1184 if (!pDevice->bShortSlotTime) {
1185 pDevice->bShortSlotTime = TRUE;
1186 BBvSetShortSlotTime(pDevice);
1187 vUpdateIFS((PVOID)pDevice);
1191 // on/off barker long preamble mode
1193 if (uLongPreambleSTACnt > 0) {
1194 if (!pDevice->bBarkerPreambleMd) {
1195 MACvEnableBarkerPreambleMd(pDevice);
1196 pDevice->bBarkerPreambleMd = TRUE;
1199 else {
1200 if (pDevice->bBarkerPreambleMd) {
1201 MACvDisableBarkerPreambleMd(pDevice);
1202 pDevice->bBarkerPreambleMd = FALSE;
1209 // Check if any STA in PS mode, enable DTIM multicast deliver
1210 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
1211 if (uSleepySTACnt > 0)
1212 pMgmt->sNodeDBTable[0].bPSEnable = TRUE;
1213 else
1214 pMgmt->sNodeDBTable[0].bPSEnable = FALSE;
1217 pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
1218 pCurrSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
1220 if ((pMgmt->eCurrMode == WMAC_MODE_STANDBY) ||
1221 (pMgmt->eCurrMode == WMAC_MODE_ESS_STA)) {
1223 if (pMgmt->sNodeDBTable[0].bActive) { // Assoc with BSS
1224 // DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "Callback inactive Count = [%d]\n", pMgmt->sNodeDBTable[0].uInActiveCount);
1226 if (pDevice->bUpdateBBVGA) {
1227 // s_vCheckSensitivity((HANDLE) pDevice);
1228 s_vCheckPreEDThreshold((HANDLE)pDevice);
1231 if ((pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2)) &&
1232 (pDevice->byBBVGACurrent != pDevice->abyBBVGA[0]) ) {
1233 pDevice->byBBVGANew = pDevice->abyBBVGA[0];
1234 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL);
1237 if (pMgmt->sNodeDBTable[0].uInActiveCount >= LOST_BEACON_COUNT) {
1238 pMgmt->sNodeDBTable[0].bActive = FALSE;
1239 pMgmt->eCurrMode = WMAC_MODE_STANDBY;
1240 pMgmt->eCurrState = WMAC_STATE_IDLE;
1241 netif_stop_queue(pDevice->dev);
1242 pDevice->bLinkPass = FALSE;
1243 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
1244 pDevice->bRoaming = TRUE;
1245 pDevice->bIsRoaming = FALSE;
1247 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost AP beacon [%d] sec, disconnected !\n", pMgmt->sNodeDBTable[0].uInActiveCount);
1248 //let wpa supplicant know AP may disconnect.//20080717-01,<Add> by James Li
1249 if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
1250 wpahdr = (viawget_wpa_header *)pDevice->skb->data;
1251 wpahdr->type = VIAWGET_DISASSOC_MSG;
1252 wpahdr->resp_ie_len = 0;
1253 wpahdr->req_ie_len = 0;
1254 skb_put(pDevice->skb, sizeof(viawget_wpa_header));
1255 pDevice->skb->dev = pDevice->wpadev;
1256 skb_reset_mac_header(pDevice->skb);
1257 pDevice->skb->pkt_type = PACKET_HOST;
1258 pDevice->skb->protocol = htons(ETH_P_802_2);
1259 memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
1260 netif_rx(pDevice->skb);
1261 pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
1263 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1264 // if(pDevice->bWPASuppWextEnabled == TRUE)
1266 union iwreq_data wrqu;
1267 memset(&wrqu, 0, sizeof (wrqu));
1268 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1269 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
1270 wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
1272 #endif
1275 else if (pItemSSID->len != 0) {
1276 //Davidwang
1277 if ((pDevice->bEnableRoaming == TRUE)&&(!(pMgmt->Cisco_cckm))) {
1278 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bRoaming %d, !\n", pDevice->bRoaming );
1279 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "bIsRoaming %d, !\n", pDevice->bIsRoaming );
1280 if ((pDevice->bRoaming == TRUE)&&(pDevice->bIsRoaming == TRUE)){
1281 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fast Roaming ...\n");
1282 BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
1283 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
1284 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
1285 pDevice->uAutoReConnectTime = 0;
1286 pDevice->uIsroamingTime = 0;
1287 pDevice->bRoaming = FALSE;
1289 // if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
1290 wpahdr = (viawget_wpa_header *)pDevice->skb->data;
1291 wpahdr->type = VIAWGET_CCKM_ROAM_MSG;
1292 wpahdr->resp_ie_len = 0;
1293 wpahdr->req_ie_len = 0;
1294 skb_put(pDevice->skb, sizeof(viawget_wpa_header));
1295 pDevice->skb->dev = pDevice->wpadev;
1296 skb_reset_mac_header(pDevice->skb);
1297 pDevice->skb->pkt_type = PACKET_HOST;
1298 pDevice->skb->protocol = htons(ETH_P_802_2);
1299 memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
1300 netif_rx(pDevice->skb);
1301 pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
1303 // }
1305 else if ((pDevice->bRoaming == FALSE)&&(pDevice->bIsRoaming == TRUE)) {
1306 pDevice->uIsroamingTime++;
1307 if (pDevice->uIsroamingTime >= 20)
1308 pDevice->bIsRoaming = FALSE;
1312 else {
1313 if (pDevice->uAutoReConnectTime < 10) {
1314 pDevice->uAutoReConnectTime++;
1315 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1316 //network manager support need not do Roaming scan???
1317 if(pDevice->bWPASuppWextEnabled ==TRUE)
1318 pDevice->uAutoReConnectTime = 0;
1319 #endif
1321 else {
1322 //mike use old encryption status for wpa reauthen
1323 if(pDevice->bWPADEVUp)
1324 pDevice->eEncryptionStatus = pDevice->eOldEncryptionStatus;
1326 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Roaming ...\n");
1327 BSSvClearBSSList((HANDLE)pDevice, pDevice->bLinkPass);
1328 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
1329 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
1330 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, pMgmt->abyDesireSSID);
1331 pDevice->uAutoReConnectTime = 0;
1337 if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
1338 // if adhoc started which essid is NULL string, rescaning.
1339 if ((pMgmt->eCurrState == WMAC_STATE_STARTED) && (pCurrSSID->len == 0)) {
1340 if (pDevice->uAutoReConnectTime < 10) {
1341 pDevice->uAutoReConnectTime++;
1343 else {
1344 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Adhoc re-scaning ...\n");
1345 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
1346 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
1347 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
1348 pDevice->uAutoReConnectTime = 0;
1351 if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
1353 if (pDevice->bUpdateBBVGA) {
1354 //s_vCheckSensitivity((HANDLE) pDevice);
1355 s_vCheckPreEDThreshold((HANDLE)pDevice);
1357 if (pMgmt->sNodeDBTable[0].uInActiveCount >=ADHOC_LOST_BEACON_COUNT) {
1358 DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost other STA beacon [%d] sec, started !\n", pMgmt->sNodeDBTable[0].uInActiveCount);
1359 pMgmt->sNodeDBTable[0].uInActiveCount = 0;
1360 pMgmt->eCurrState = WMAC_STATE_STARTED;
1361 netif_stop_queue(pDevice->dev);
1362 pDevice->bLinkPass = FALSE;
1363 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
1368 if (pDevice->bLinkPass == TRUE) {
1369 if (netif_queue_stopped(pDevice->dev))
1370 netif_wake_queue(pDevice->dev);
1373 spin_unlock_irq(&pDevice->lock);
1375 pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ);
1376 add_timer(&pMgmt->sTimerSecondCallback);
1377 return;
1385 * Routine Description:
1388 * Update Tx attemps, Tx failure counter in Node DB
1391 * Return Value:
1392 * none.
1398 VOID
1399 BSSvUpdateNodeTxCounter(
1400 IN HANDLE hDeviceContext,
1401 IN PSStatCounter pStatistic,
1402 IN BYTE byTSR,
1403 IN BYTE byPktNO
1406 PSDevice pDevice = (PSDevice)hDeviceContext;
1407 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1408 UINT uNodeIndex = 0;
1409 BYTE byTxRetry;
1410 WORD wRate;
1411 WORD wFallBackRate = RATE_1M;
1412 BYTE byFallBack;
1413 UINT ii;
1414 PBYTE pbyDestAddr;
1415 BYTE byPktNum;
1416 WORD wFIFOCtl;
1420 byPktNum = (byPktNO & 0x0F) >> 4;
1421 byTxRetry = (byTSR & 0xF0) >> 4;
1422 wRate = (WORD) (byPktNO & 0xF0) >> 4;
1423 wFIFOCtl = pStatistic->abyTxPktInfo[byPktNum].wFIFOCtl;
1424 pbyDestAddr = (PBYTE) &( pStatistic->abyTxPktInfo[byPktNum].abyDestAddr[0]);
1426 if (wFIFOCtl & FIFOCTL_AUTO_FB_0) {
1427 byFallBack = AUTO_FB_0;
1428 } else if (wFIFOCtl & FIFOCTL_AUTO_FB_1) {
1429 byFallBack = AUTO_FB_1;
1430 } else {
1431 byFallBack = AUTO_FB_NONE;
1434 // Only Unicast using support rates
1435 if (wFIFOCtl & FIFOCTL_NEEDACK) {
1436 //DBG_PRN_GRP21(("Device %08X, wRate %04X, byTSR %02X\n", hDeviceContext, wRate, byTSR));
1437 if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA) {
1438 pMgmt->sNodeDBTable[0].uTxAttempts += 1;
1439 if ( !(byTSR & (TSR_TMO | TSR_RETRYTMO))) {
1440 // transmit success, TxAttempts at least plus one
1441 pMgmt->sNodeDBTable[0].uTxOk[MAX_RATE]++;
1442 if ( (byFallBack == AUTO_FB_NONE) ||
1443 (wRate < RATE_18M) ) {
1444 wFallBackRate = wRate;
1445 } else if (byFallBack == AUTO_FB_0) {
1446 if (byTxRetry < 5)
1447 wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry];
1448 else
1449 wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
1450 } else if (byFallBack == AUTO_FB_1) {
1451 if (byTxRetry < 5)
1452 wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry];
1453 else
1454 wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
1456 pMgmt->sNodeDBTable[0].uTxOk[wFallBackRate]++;
1457 } else {
1458 pMgmt->sNodeDBTable[0].uTxFailures ++;
1460 pMgmt->sNodeDBTable[0].uTxRetry += byTxRetry;
1461 if (byTxRetry != 0) {
1462 pMgmt->sNodeDBTable[0].uTxFail[MAX_RATE]+=byTxRetry;
1463 if ( (byFallBack == AUTO_FB_NONE) ||
1464 (wRate < RATE_18M) ) {
1465 pMgmt->sNodeDBTable[0].uTxFail[wRate]+=byTxRetry;
1466 } else if (byFallBack == AUTO_FB_0) {
1467 for(ii=0;ii<byTxRetry;ii++) {
1468 if (ii < 5)
1469 wFallBackRate = awHWRetry0[wRate-RATE_18M][ii];
1470 else
1471 wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
1472 pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++;
1474 } else if (byFallBack == AUTO_FB_1) {
1475 for(ii=0;ii<byTxRetry;ii++) {
1476 if (ii < 5)
1477 wFallBackRate = awHWRetry1[wRate-RATE_18M][ii];
1478 else
1479 wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
1480 pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++;
1486 if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
1487 (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
1489 if (BSSbIsSTAInNodeDB((HANDLE)pDevice, pbyDestAddr, &uNodeIndex)){
1490 pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts += 1;
1491 if ( !(byTSR & (TSR_TMO | TSR_RETRYTMO))) {
1492 // transmit success, TxAttempts at least plus one
1493 pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
1494 if ( (byFallBack == AUTO_FB_NONE) ||
1495 (wRate < RATE_18M) ) {
1496 wFallBackRate = wRate;
1497 } else if (byFallBack == AUTO_FB_0) {
1498 if (byTxRetry < 5)
1499 wFallBackRate = awHWRetry0[wRate-RATE_18M][byTxRetry];
1500 else
1501 wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
1502 } else if (byFallBack == AUTO_FB_1) {
1503 if (byTxRetry < 5)
1504 wFallBackRate = awHWRetry1[wRate-RATE_18M][byTxRetry];
1505 else
1506 wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
1508 pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wFallBackRate]++;
1509 } else {
1510 pMgmt->sNodeDBTable[uNodeIndex].uTxFailures ++;
1512 pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += byTxRetry;
1513 if (byTxRetry != 0) {
1514 pMgmt->sNodeDBTable[uNodeIndex].uTxFail[MAX_RATE]+=byTxRetry;
1515 if ( (byFallBack == AUTO_FB_NONE) ||
1516 (wRate < RATE_18M) ) {
1517 pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wRate]+=byTxRetry;
1518 } else if (byFallBack == AUTO_FB_0) {
1519 for(ii=0;ii<byTxRetry;ii++) {
1520 if (ii < 5)
1521 wFallBackRate = awHWRetry0[wRate-RATE_18M][ii];
1522 else
1523 wFallBackRate = awHWRetry0[wRate-RATE_18M][4];
1524 pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++;
1526 } else if (byFallBack == AUTO_FB_1) {
1527 for(ii=0;ii<byTxRetry;ii++) {
1528 if (ii < 5)
1529 wFallBackRate = awHWRetry1[wRate-RATE_18M][ii];
1530 else
1531 wFallBackRate = awHWRetry1[wRate-RATE_18M][4];
1532 pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++;
1540 return;
1550 * Routine Description:
1551 * Clear Nodes & skb in DB Table
1554 * Parameters:
1555 * In:
1556 * hDeviceContext - The adapter context.
1557 * uStartIndex - starting index
1558 * Out:
1559 * none
1561 * Return Value:
1562 * None.
1567 VOID
1568 BSSvClearNodeDBTable(
1569 IN HANDLE hDeviceContext,
1570 IN UINT uStartIndex
1574 PSDevice pDevice = (PSDevice)hDeviceContext;
1575 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1576 struct sk_buff *skb;
1577 UINT ii;
1579 for (ii = uStartIndex; ii < (MAX_NODE_NUM + 1); ii++) {
1580 if (pMgmt->sNodeDBTable[ii].bActive) {
1581 // check if sTxPSQueue has been initial
1582 if (pMgmt->sNodeDBTable[ii].sTxPSQueue.next != NULL) {
1583 while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[ii].sTxPSQueue)) != NULL){
1584 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PS skb != NULL %d\n", ii);
1585 dev_kfree_skb(skb);
1588 memset(&pMgmt->sNodeDBTable[ii], 0, sizeof(KnownNodeDB));
1592 return;
1596 VOID s_vCheckSensitivity(
1597 IN HANDLE hDeviceContext
1600 PSDevice pDevice = (PSDevice)hDeviceContext;
1601 PKnownBSS pBSSList = NULL;
1602 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1603 int ii;
1605 if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
1606 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
1607 pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID);
1608 if (pBSSList != NULL) {
1609 // Updata BB Reg if RSSI is too strong.
1610 LONG LocalldBmAverage = 0;
1611 LONG uNumofdBm = 0;
1612 for (ii = 0; ii < RSSI_STAT_COUNT; ii++) {
1613 if (pBSSList->ldBmAverage[ii] != 0) {
1614 uNumofdBm ++;
1615 LocalldBmAverage += pBSSList->ldBmAverage[ii];
1618 if (uNumofdBm > 0) {
1619 LocalldBmAverage = LocalldBmAverage/uNumofdBm;
1620 for (ii=0;ii<BB_VGA_LEVEL;ii++) {
1621 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"LocalldBmAverage:%ld, %ld %02x\n", LocalldBmAverage, pDevice->ldBmThreshold[ii], pDevice->abyBBVGA[ii]);
1622 if (LocalldBmAverage < pDevice->ldBmThreshold[ii]) {
1623 pDevice->byBBVGANew = pDevice->abyBBVGA[ii];
1624 break;
1627 if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
1628 pDevice->uBBVGADiffCount++;
1629 if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD)
1630 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_BBSENSITIVITY, NULL);
1631 } else {
1632 pDevice->uBBVGADiffCount = 0;
1639 #ifdef Calcu_LinkQual
1640 VOID s_uCalculateLinkQual(
1641 IN HANDLE hDeviceContext
1644 PSDevice pDevice = (PSDevice)hDeviceContext;
1645 ULONG TxOkRatio, TxCnt;
1646 ULONG RxOkRatio,RxCnt;
1647 ULONG RssiRatio;
1648 long ldBm;
1650 TxCnt = pDevice->scStatistic.TxNoRetryOkCount +
1651 pDevice->scStatistic.TxRetryOkCount +
1652 pDevice->scStatistic.TxFailCount;
1653 RxCnt = pDevice->scStatistic.RxFcsErrCnt +
1654 pDevice->scStatistic.RxOkCnt;
1655 TxOkRatio = (TxCnt < 6) ? 4000:((pDevice->scStatistic.TxNoRetryOkCount * 4000) / TxCnt);
1656 RxOkRatio = (RxCnt < 6) ? 2000:((pDevice->scStatistic.RxOkCnt * 2000) / RxCnt);
1657 //decide link quality
1658 if(pDevice->bLinkPass !=TRUE)
1660 // printk("s_uCalculateLinkQual-->Link disconnect and Poor quality**\n");
1661 pDevice->scStatistic.LinkQuality = 0;
1662 pDevice->scStatistic.SignalStren = 0;
1664 else
1666 RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
1667 if(-ldBm < 50) {
1668 RssiRatio = 4000;
1670 else if(-ldBm > 90) {
1671 RssiRatio = 0;
1673 else {
1674 RssiRatio = (40-(-ldBm-50))*4000/40;
1676 pDevice->scStatistic.SignalStren = RssiRatio/40;
1677 pDevice->scStatistic.LinkQuality = (RssiRatio+TxOkRatio+RxOkRatio)/100;
1679 pDevice->scStatistic.RxFcsErrCnt = 0;
1680 pDevice->scStatistic.RxOkCnt = 0;
1681 pDevice->scStatistic.TxFailCount = 0;
1682 pDevice->scStatistic.TxNoRetryOkCount = 0;
1683 pDevice->scStatistic.TxRetryOkCount = 0;
1684 return;
1686 #endif
1688 VOID
1689 BSSvClearAnyBSSJoinRecord (
1690 IN HANDLE hDeviceContext
1693 PSDevice pDevice = (PSDevice)hDeviceContext;
1694 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1695 UINT ii;
1697 for (ii = 0; ii < MAX_BSS_NUM; ii++) {
1698 pMgmt->sBSSList[ii].bSelected = FALSE;
1700 return;
1703 VOID s_vCheckPreEDThreshold(
1704 IN HANDLE hDeviceContext
1707 PSDevice pDevice = (PSDevice)hDeviceContext;
1708 PKnownBSS pBSSList = NULL;
1709 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1711 if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
1712 ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
1713 pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID);
1714 if (pBSSList != NULL) {
1715 pDevice->byBBPreEDRSSI = (BYTE) (~(pBSSList->ldBmAverRange) + 1);
1716 BBvUpdatePreEDThreshold(pDevice, FALSE);
1719 return;