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 * 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
61 static int msglevel
=MSG_LEVEL_INFO
;
62 //static int msglevel =MSG_LEVEL_DEBUG;
64 const u16 awHWRetry0
[5][5] = {
65 {RATE_18M
, RATE_18M
, RATE_12M
, RATE_12M
, RATE_12M
},
66 {RATE_24M
, RATE_24M
, RATE_18M
, RATE_12M
, RATE_12M
},
67 {RATE_36M
, RATE_36M
, RATE_24M
, RATE_18M
, RATE_18M
},
68 {RATE_48M
, RATE_48M
, RATE_36M
, RATE_24M
, RATE_24M
},
69 {RATE_54M
, RATE_54M
, RATE_48M
, RATE_36M
, RATE_36M
}
71 const u16 awHWRetry1
[5][5] = {
72 {RATE_18M
, RATE_18M
, RATE_12M
, RATE_6M
, RATE_6M
},
73 {RATE_24M
, RATE_24M
, RATE_18M
, RATE_6M
, RATE_6M
},
74 {RATE_36M
, RATE_36M
, RATE_24M
, RATE_12M
, RATE_12M
},
75 {RATE_48M
, RATE_48M
, RATE_24M
, RATE_12M
, RATE_12M
},
76 {RATE_54M
, RATE_54M
, RATE_36M
, RATE_18M
, RATE_18M
}
79 static void s_vCheckSensitivity(struct vnt_private
*pDevice
);
80 static void s_vCheckPreEDThreshold(struct vnt_private
*pDevice
);
81 static void s_uCalculateLinkQual(struct vnt_private
*pDevice
);
85 * Routine Description:
86 * Search known BSS list for Desire SSID or BSSID.
89 * PTR to KnownBSS or NULL
93 PKnownBSS
BSSpSearchBSSList(struct vnt_private
*pDevice
,
94 u8
*pbyDesireBSSID
, u8
*pbyDesireSSID
,
95 CARD_PHY_TYPE ePhyType
)
97 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
99 PWLAN_IE_SSID pSSID
= NULL
;
100 PKnownBSS pCurrBSS
= NULL
;
101 PKnownBSS pSelect
= NULL
;
102 u8 ZeroBSSID
[WLAN_BSSID_LEN
] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
106 if (pbyDesireBSSID
!= NULL
) {
107 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
108 "BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID
);
109 if ((!is_broadcast_ether_addr(pbyDesireBSSID
)) &&
110 (memcmp(pbyDesireBSSID
, ZeroBSSID
, 6)!= 0)){
111 pbyBSSID
= pbyDesireBSSID
;
114 if (pbyDesireSSID
!= NULL
) {
115 if (((PWLAN_IE_SSID
)pbyDesireSSID
)->len
!= 0) {
116 pSSID
= (PWLAN_IE_SSID
) pbyDesireSSID
;
120 if ((pbyBSSID
!= NULL
)&&(pDevice
->bRoaming
== false)) {
122 for (ii
= 0; ii
<MAX_BSS_NUM
; ii
++) {
123 pCurrBSS
= &(pMgmt
->sBSSList
[ii
]);
125 pCurrBSS
->bSelected
= false;
127 if ((pCurrBSS
->bActive
) &&
128 (pCurrBSS
->bSelected
== false)) {
129 if (!compare_ether_addr(pCurrBSS
->abyBSSID
, pbyBSSID
)) {
132 if ( !memcmp(pSSID
->abySSID
,
133 ((PWLAN_IE_SSID
)pCurrBSS
->abySSID
)->abySSID
,
135 if ((pMgmt
->eConfigMode
== WMAC_CONFIG_AUTO
) ||
136 ((pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS
->wCapInfo
)) ||
137 ((pMgmt
->eConfigMode
== WMAC_CONFIG_ESS_STA
) && WLAN_GET_CAP_INFO_ESS(pCurrBSS
->wCapInfo
))
139 pCurrBSS
->bSelected
= true;
144 if ((pMgmt
->eConfigMode
== WMAC_CONFIG_AUTO
) ||
145 ((pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS
->wCapInfo
)) ||
146 ((pMgmt
->eConfigMode
== WMAC_CONFIG_ESS_STA
) && WLAN_GET_CAP_INFO_ESS(pCurrBSS
->wCapInfo
))
148 pCurrBSS
->bSelected
= true;
157 for (ii
= 0; ii
<MAX_BSS_NUM
; ii
++) {
158 pCurrBSS
= &(pMgmt
->sBSSList
[ii
]);
160 //2007-0721-01<Mark>by MikeLiu
161 // if ((pCurrBSS->bActive) &&
162 // (pCurrBSS->bSelected == false)) {
164 pCurrBSS
->bSelected
= false;
165 if (pCurrBSS
->bActive
) {
169 if (memcmp(pSSID
->abySSID
,
170 ((PWLAN_IE_SSID
)pCurrBSS
->abySSID
)->abySSID
,
172 (pSSID
->len
!= ((PWLAN_IE_SSID
)pCurrBSS
->abySSID
)->len
)) {
173 // SSID not match skip this BSS
177 if (((pMgmt
->eConfigMode
== WMAC_CONFIG_IBSS_STA
) && WLAN_GET_CAP_INFO_ESS(pCurrBSS
->wCapInfo
)) ||
178 ((pMgmt
->eConfigMode
== WMAC_CONFIG_ESS_STA
) && WLAN_GET_CAP_INFO_IBSS(pCurrBSS
->wCapInfo
))
180 // Type not match skip this BSS
181 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BSS type mismatch.... Config[%d] BSS[0x%04x]\n", pMgmt
->eConfigMode
, pCurrBSS
->wCapInfo
);
185 if (ePhyType
!= PHY_TYPE_AUTO
) {
186 if (((ePhyType
== PHY_TYPE_11A
) && (PHY_TYPE_11A
!= pCurrBSS
->eNetworkTypeInUse
)) ||
187 ((ePhyType
!= PHY_TYPE_11A
) && (PHY_TYPE_11A
== pCurrBSS
->eNetworkTypeInUse
))) {
188 // PhyType not match skip this BSS
189 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Physical type mismatch.... ePhyType[%d] BSS[%d]\n", ePhyType
, pCurrBSS
->eNetworkTypeInUse
);
194 pMgmt
->pSameBSS
[jj
].uChannel
= pCurrBSS
->uChannel
;
195 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
196 "BSSpSearchBSSList pSelect1[%pM]\n",
200 if (pSelect
== NULL
) {
203 // compare RSSI, select the strongest signal
204 if (pCurrBSS
->uRSSI
< pSelect
->uRSSI
) {
211 pDevice
->bSameBSSMaxNum
= jj
;
213 if (pSelect
!= NULL
) {
214 pSelect
->bSelected
= true;
215 if (pDevice
->bRoaming
== false) {
216 // Einsn Add @20070907
217 memcpy(pbyDesireSSID
,pCurrBSS
->abySSID
,WLAN_IEHDR_LEN
+ WLAN_SSID_MAXLEN
+ 1) ;
229 * Routine Description:
237 void BSSvClearBSSList(struct vnt_private
*pDevice
, int bKeepCurrBSSID
)
239 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
242 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
243 if (bKeepCurrBSSID
) {
244 if (pMgmt
->sBSSList
[ii
].bActive
&&
245 !compare_ether_addr(pMgmt
->sBSSList
[ii
].abyBSSID
,
246 pMgmt
->abyCurrBSSID
)) {
247 //mike mark: there are two BSSID's in list. If that AP is in hidden ssid mode, one SSID is null,
248 // but other's might not be obvious, so if it associate's with your STA,
249 // you must keep the two of them!!
250 // bKeepCurrBSSID = false;
255 pMgmt
->sBSSList
[ii
].bActive
= false;
256 memset(&pMgmt
->sBSSList
[ii
], 0, sizeof(KnownBSS
));
258 BSSvClearAnyBSSJoinRecord(pDevice
);
263 * Routine Description:
264 * search BSS list by BSSID & SSID if matched
270 PKnownBSS
BSSpAddrIsInBSSList(struct vnt_private
*pDevice
,
271 u8
*abyBSSID
, PWLAN_IE_SSID pSSID
)
273 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
274 PKnownBSS pBSSList
= NULL
;
277 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
278 pBSSList
= &(pMgmt
->sBSSList
[ii
]);
279 if (pBSSList
->bActive
) {
280 if (!compare_ether_addr(pBSSList
->abyBSSID
, abyBSSID
)) {
281 if (pSSID
->len
== ((PWLAN_IE_SSID
)pBSSList
->abySSID
)->len
){
282 if (memcmp(pSSID
->abySSID
,
283 ((PWLAN_IE_SSID
)pBSSList
->abySSID
)->abySSID
,
296 * Routine Description:
297 * Insert a BSS set into known BSS list
304 int BSSbInsertToBSSList(struct vnt_private
*pDevice
,
311 PWLAN_IE_SUPP_RATES pSuppRates
,
312 PWLAN_IE_SUPP_RATES pExtSuppRates
,
315 PWLAN_IE_RSN_EXT pRSNWPA
,
316 PWLAN_IE_COUNTRY pIE_Country
,
317 PWLAN_IE_QUIET pIE_Quiet
,
320 void *pRxPacketContext
)
322 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
323 struct vnt_rx_mgmt
*pRxPacket
=
324 (struct vnt_rx_mgmt
*)pRxPacketContext
;
325 PKnownBSS pBSSList
= NULL
;
327 bool bParsingQuiet
= false;
329 pBSSList
= (PKnownBSS
)&(pMgmt
->sBSSList
[0]);
331 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++) {
332 pBSSList
= (PKnownBSS
)&(pMgmt
->sBSSList
[ii
]);
333 if (!pBSSList
->bActive
)
337 if (ii
== MAX_BSS_NUM
){
338 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get free KnowBSS node failed.\n");
342 pBSSList
->bActive
= true;
343 memcpy( pBSSList
->abyBSSID
, abyBSSIDAddr
, WLAN_BSSID_LEN
);
344 pBSSList
->qwBSSTimestamp
= cpu_to_le64(qwTimestamp
);
345 pBSSList
->wBeaconInterval
= cpu_to_le16(wBeaconInterval
);
346 pBSSList
->wCapInfo
= cpu_to_le16(wCapInfo
);
347 pBSSList
->uClearCount
= 0;
349 if (pSSID
->len
> WLAN_SSID_MAXLEN
)
350 pSSID
->len
= WLAN_SSID_MAXLEN
;
351 memcpy( pBSSList
->abySSID
, pSSID
, pSSID
->len
+ WLAN_IEHDR_LEN
);
353 pBSSList
->uChannel
= byCurrChannel
;
355 if (pSuppRates
->len
> WLAN_RATES_MAXLEN
)
356 pSuppRates
->len
= WLAN_RATES_MAXLEN
;
357 memcpy( pBSSList
->abySuppRates
, pSuppRates
, pSuppRates
->len
+ WLAN_IEHDR_LEN
);
359 if (pExtSuppRates
!= NULL
) {
360 if (pExtSuppRates
->len
> WLAN_RATES_MAXLEN
)
361 pExtSuppRates
->len
= WLAN_RATES_MAXLEN
;
362 memcpy(pBSSList
->abyExtSuppRates
, pExtSuppRates
, pExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
363 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"BSSbInsertToBSSList: pExtSuppRates->len = %d\n", pExtSuppRates
->len
);
366 memset(pBSSList
->abyExtSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
368 pBSSList
->sERP
.byERP
= psERP
->byERP
;
369 pBSSList
->sERP
.bERPExist
= psERP
->bERPExist
;
371 // Check if BSS is 802.11a/b/g
372 if (pBSSList
->uChannel
> CB_MAX_CHANNEL_24G
) {
373 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11A
;
375 if (pBSSList
->sERP
.bERPExist
== true) {
376 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11G
;
378 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11B
;
382 pBSSList
->byRxRate
= pRxPacket
->byRxRate
;
383 pBSSList
->qwLocalTSF
= pRxPacket
->qwLocalTSF
;
384 pBSSList
->uRSSI
= pRxPacket
->uRSSI
;
385 pBSSList
->bySQ
= pRxPacket
->bySQ
;
387 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
388 (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
390 if (pBSSList
== pMgmt
->pCurrBSS
) {
391 bParsingQuiet
= true;
395 WPA_ClearRSN(pBSSList
);
397 if (pRSNWPA
!= NULL
) {
398 unsigned int uLen
= pRSNWPA
->len
+ 2;
400 if (uLen
<= (uIELength
-
401 (unsigned int) (u32
) ((u8
*) pRSNWPA
- pbyIEs
))) {
402 pBSSList
->wWPALen
= uLen
;
403 memcpy(pBSSList
->byWPAIE
, pRSNWPA
, uLen
);
404 WPA_ParseRSN(pBSSList
, pRSNWPA
);
408 WPA2_ClearRSN(pBSSList
);
411 unsigned int uLen
= pRSN
->len
+ 2;
413 if (uLen
<= (uIELength
-
414 (unsigned int) (u32
) ((u8
*) pRSN
- pbyIEs
))) {
415 pBSSList
->wRSNLen
= uLen
;
416 memcpy(pBSSList
->byRSNIE
, pRSN
, uLen
);
417 WPA2vParseRSN(pBSSList
, pRSN
);
421 if ((pMgmt
->eAuthenMode
== WMAC_AUTH_WPA2
) || (pBSSList
->bWPA2Valid
== true)) {
423 PSKeyItem pTransmitKey
= NULL
;
424 bool bIs802_1x
= false;
426 for (ii
= 0; ii
< pBSSList
->wAKMSSAuthCount
; ii
++) {
427 if (pBSSList
->abyAKMSSAuthType
[ii
] == WLAN_11i_AKMSS_802_1X
) {
432 if ((bIs802_1x
== true) && (pSSID
->len
== ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->len
) &&
433 ( !memcmp(pSSID
->abySSID
, ((PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
)->abySSID
, pSSID
->len
))) {
435 bAdd_PMKID_Candidate((void *) pDevice
,
437 &pBSSList
->sRSNCapObj
);
439 if ((pDevice
->bLinkPass
== true) && (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
440 if ((KeybGetTransmitKey(&(pDevice
->sKey
), pDevice
->abyBSSID
, PAIRWISE_KEY
, &pTransmitKey
) == true) ||
441 (KeybGetTransmitKey(&(pDevice
->sKey
), pDevice
->abyBSSID
, GROUP_KEY
, &pTransmitKey
) == true)) {
442 pDevice
->gsPMKIDCandidate
.StatusType
= Ndis802_11StatusType_PMKID_CandidateList
;
443 pDevice
->gsPMKIDCandidate
.Version
= 1;
451 if (pDevice
->bUpdateBBVGA
) {
452 // Monitor if RSSI is too strong.
453 pBSSList
->byRSSIStatCnt
= 0;
454 RFvRSSITodBm(pDevice
, (u8
)(pRxPacket
->uRSSI
), &pBSSList
->ldBmMAX
);
455 pBSSList
->ldBmAverage
[0] = pBSSList
->ldBmMAX
;
456 pBSSList
->ldBmAverRange
= pBSSList
->ldBmMAX
;
457 for (ii
= 1; ii
< RSSI_STAT_COUNT
; ii
++)
458 pBSSList
->ldBmAverage
[ii
] = 0;
461 pBSSList
->uIELength
= uIELength
;
462 if (pBSSList
->uIELength
> WLAN_BEACON_FR_MAXLEN
)
463 pBSSList
->uIELength
= WLAN_BEACON_FR_MAXLEN
;
464 memcpy(pBSSList
->abyIEs
, pbyIEs
, pBSSList
->uIELength
);
471 * Routine Description:
472 * Update BSS set in known BSS list
478 // TODO: input structure modify
480 int BSSbUpdateToBSSList(struct vnt_private
*pDevice
,
487 PWLAN_IE_SUPP_RATES pSuppRates
,
488 PWLAN_IE_SUPP_RATES pExtSuppRates
,
491 PWLAN_IE_RSN_EXT pRSNWPA
,
492 PWLAN_IE_COUNTRY pIE_Country
,
493 PWLAN_IE_QUIET pIE_Quiet
,
497 void *pRxPacketContext
)
499 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
500 struct vnt_rx_mgmt
*pRxPacket
=
501 (struct vnt_rx_mgmt
*)pRxPacketContext
;
503 signed long ldBm
, ldBmSum
;
504 bool bParsingQuiet
= false;
506 if (pBSSList
== NULL
)
509 pBSSList
->qwBSSTimestamp
= cpu_to_le64(qwTimestamp
);
511 pBSSList
->wBeaconInterval
= cpu_to_le16(wBeaconInterval
);
512 pBSSList
->wCapInfo
= cpu_to_le16(wCapInfo
);
513 pBSSList
->uClearCount
= 0;
514 pBSSList
->uChannel
= byCurrChannel
;
516 if (pSSID
->len
> WLAN_SSID_MAXLEN
)
517 pSSID
->len
= WLAN_SSID_MAXLEN
;
519 if ((pSSID
->len
!= 0) && (pSSID
->abySSID
[0] != 0))
520 memcpy(pBSSList
->abySSID
, pSSID
, pSSID
->len
+ WLAN_IEHDR_LEN
);
521 memcpy(pBSSList
->abySuppRates
, pSuppRates
,pSuppRates
->len
+ WLAN_IEHDR_LEN
);
523 if (pExtSuppRates
!= NULL
) {
524 memcpy(pBSSList
->abyExtSuppRates
, pExtSuppRates
,pExtSuppRates
->len
+ WLAN_IEHDR_LEN
);
526 memset(pBSSList
->abyExtSuppRates
, 0, WLAN_IEHDR_LEN
+ WLAN_RATES_MAXLEN
+ 1);
528 pBSSList
->sERP
.byERP
= psERP
->byERP
;
529 pBSSList
->sERP
.bERPExist
= psERP
->bERPExist
;
531 // Check if BSS is 802.11a/b/g
532 if (pBSSList
->uChannel
> CB_MAX_CHANNEL_24G
) {
533 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11A
;
535 if (pBSSList
->sERP
.bERPExist
== true) {
536 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11G
;
538 pBSSList
->eNetworkTypeInUse
= PHY_TYPE_11B
;
542 pBSSList
->byRxRate
= pRxPacket
->byRxRate
;
543 pBSSList
->qwLocalTSF
= pRxPacket
->qwLocalTSF
;
545 pBSSList
->uRSSI
= pRxPacket
->uRSSI
;
546 pBSSList
->bySQ
= pRxPacket
->bySQ
;
548 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
549 (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
551 if (pBSSList
== pMgmt
->pCurrBSS
) {
552 bParsingQuiet
= true;
556 WPA_ClearRSN(pBSSList
); //mike update
558 if (pRSNWPA
!= NULL
) {
559 unsigned int uLen
= pRSNWPA
->len
+ 2;
560 if (uLen
<= (uIELength
-
561 (unsigned int) (u32
) ((u8
*) pRSNWPA
- pbyIEs
))) {
562 pBSSList
->wWPALen
= uLen
;
563 memcpy(pBSSList
->byWPAIE
, pRSNWPA
, uLen
);
564 WPA_ParseRSN(pBSSList
, pRSNWPA
);
568 WPA2_ClearRSN(pBSSList
); //mike update
571 unsigned int uLen
= pRSN
->len
+ 2;
572 if (uLen
<= (uIELength
-
573 (unsigned int) (u32
) ((u8
*) pRSN
- pbyIEs
))) {
574 pBSSList
->wRSNLen
= uLen
;
575 memcpy(pBSSList
->byRSNIE
, pRSN
, uLen
);
576 WPA2vParseRSN(pBSSList
, pRSN
);
580 if (pRxPacket
->uRSSI
!= 0) {
581 RFvRSSITodBm(pDevice
, (u8
)(pRxPacket
->uRSSI
), &ldBm
);
582 // Monitor if RSSI is too strong.
583 pBSSList
->byRSSIStatCnt
++;
584 pBSSList
->byRSSIStatCnt
%= RSSI_STAT_COUNT
;
585 pBSSList
->ldBmAverage
[pBSSList
->byRSSIStatCnt
] = ldBm
;
587 for (ii
= 0, jj
= 0; ii
< RSSI_STAT_COUNT
; ii
++) {
588 if (pBSSList
->ldBmAverage
[ii
] != 0) {
590 max(pBSSList
->ldBmAverage
[ii
], ldBm
);
592 pBSSList
->ldBmAverage
[ii
];
596 pBSSList
->ldBmAverRange
= ldBmSum
/jj
;
599 pBSSList
->uIELength
= uIELength
;
600 if (pBSSList
->uIELength
> WLAN_BEACON_FR_MAXLEN
)
601 pBSSList
->uIELength
= WLAN_BEACON_FR_MAXLEN
;
602 memcpy(pBSSList
->abyIEs
, pbyIEs
, pBSSList
->uIELength
);
609 * Routine Description:
610 * Search Node DB table to find the index of matched DstAddr
617 int BSSbIsSTAInNodeDB(struct vnt_private
*pDevice
,
618 u8
*abyDstAddr
, u32
*puNodeIndex
)
620 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
623 // Index = 0 reserved for AP Node
624 for (ii
= 1; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
625 if (pMgmt
->sNodeDBTable
[ii
].bActive
) {
626 if (!compare_ether_addr(abyDstAddr
,
627 pMgmt
->sNodeDBTable
[ii
].abyMACAddr
)) {
639 * Routine Description:
640 * Find an empty node and allocate it; if no empty node
641 * is found, then use the most inactive one.
647 void BSSvCreateOneNode(struct vnt_private
*pDevice
, u32
*puNodeIndex
)
649 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
655 // Index = 0 reserved for AP Node (In STA mode)
656 // Index = 0 reserved for Broadcast/MultiCast (In AP mode)
658 for (ii
= 1; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
659 if (pMgmt
->sNodeDBTable
[ii
].bActive
) {
660 if (pMgmt
->sNodeDBTable
[ii
].uInActiveCount
> BigestCount
) {
661 BigestCount
= pMgmt
->sNodeDBTable
[ii
].uInActiveCount
;
670 // if not found replace uInActiveCount with the largest one.
671 if ( ii
== (MAX_NODE_NUM
+ 1)) {
672 *puNodeIndex
= SelectIndex
;
673 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Replace inactive node = %d\n", SelectIndex
);
675 if (pMgmt
->sNodeDBTable
[*puNodeIndex
].sTxPSQueue
.next
!= NULL
) {
676 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[*puNodeIndex
].sTxPSQueue
)) != NULL
)
684 memset(&pMgmt
->sNodeDBTable
[*puNodeIndex
], 0, sizeof(KnownNodeDB
));
685 pMgmt
->sNodeDBTable
[*puNodeIndex
].bActive
= true;
686 pMgmt
->sNodeDBTable
[*puNodeIndex
].uRatePollTimeout
= FALLBACK_POLL_SECOND
;
687 // for AP mode PS queue
688 skb_queue_head_init(&pMgmt
->sNodeDBTable
[*puNodeIndex
].sTxPSQueue
);
689 pMgmt
->sNodeDBTable
[*puNodeIndex
].byAuthSequence
= 0;
690 pMgmt
->sNodeDBTable
[*puNodeIndex
].wEnQueueCnt
= 0;
691 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Create node index = %d\n", ii
);
696 * Routine Description:
697 * Remove Node by NodeIndex
705 void BSSvRemoveOneNode(struct vnt_private
*pDevice
, u32 uNodeIndex
)
707 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
708 u8 byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
711 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[uNodeIndex
].sTxPSQueue
)) != NULL
)
714 memset(&pMgmt
->sNodeDBTable
[uNodeIndex
], 0, sizeof(KnownNodeDB
));
716 pMgmt
->abyPSTxMap
[pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
>> 3] &= ~byMask
[pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
& 7];
720 * Routine Description:
721 * Update AP Node content in Index 0 of KnownNodeDB
729 void BSSvUpdateAPNode(struct vnt_private
*pDevice
, u16
*pwCapInfo
,
730 PWLAN_IE_SUPP_RATES pSuppRates
, PWLAN_IE_SUPP_RATES pExtSuppRates
)
732 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
733 u32 uRateLen
= WLAN_RATES_MAXLEN
;
735 memset(&pMgmt
->sNodeDBTable
[0], 0, sizeof(KnownNodeDB
));
737 pMgmt
->sNodeDBTable
[0].bActive
= true;
738 if (pDevice
->byBBType
== BB_TYPE_11B
) {
739 uRateLen
= WLAN_RATES_MAXLEN_11B
;
741 pMgmt
->abyCurrSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pSuppRates
,
742 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
744 pMgmt
->abyCurrExtSuppRates
[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES
)pExtSuppRates
,
745 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
747 RATEvParseMaxRate((void *) pDevice
,
748 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
749 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
751 &(pMgmt
->sNodeDBTable
[0].wMaxBasicRate
),
752 &(pMgmt
->sNodeDBTable
[0].wMaxSuppRate
),
753 &(pMgmt
->sNodeDBTable
[0].wSuppRate
),
754 &(pMgmt
->sNodeDBTable
[0].byTopCCKBasicRate
),
755 &(pMgmt
->sNodeDBTable
[0].byTopOFDMBasicRate
)
757 memcpy(pMgmt
->sNodeDBTable
[0].abyMACAddr
, pMgmt
->abyCurrBSSID
, WLAN_ADDR_LEN
);
758 pMgmt
->sNodeDBTable
[0].wTxDataRate
= pMgmt
->sNodeDBTable
[0].wMaxSuppRate
;
759 pMgmt
->sNodeDBTable
[0].bShortPreamble
= WLAN_GET_CAP_INFO_SHORTPREAMBLE(*pwCapInfo
);
760 pMgmt
->sNodeDBTable
[0].uRatePollTimeout
= FALLBACK_POLL_SECOND
;
761 // Auto rate fallback function initiation.
762 // RATEbInit(pDevice);
763 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"pMgmt->sNodeDBTable[0].wTxDataRate = %d \n", pMgmt
->sNodeDBTable
[0].wTxDataRate
);
769 * Routine Description:
770 * Add Multicast Node content in Index 0 of KnownNodeDB
778 void BSSvAddMulticastNode(struct vnt_private
*pDevice
)
780 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
782 if (!pDevice
->bEnableHostWEP
)
783 memset(&pMgmt
->sNodeDBTable
[0], 0, sizeof(KnownNodeDB
));
784 memset(pMgmt
->sNodeDBTable
[0].abyMACAddr
, 0xff, WLAN_ADDR_LEN
);
785 pMgmt
->sNodeDBTable
[0].bActive
= true;
786 pMgmt
->sNodeDBTable
[0].bPSEnable
= false;
787 skb_queue_head_init(&pMgmt
->sNodeDBTable
[0].sTxPSQueue
);
788 RATEvParseMaxRate((void *) pDevice
,
789 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
,
790 (PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
,
792 &(pMgmt
->sNodeDBTable
[0].wMaxBasicRate
),
793 &(pMgmt
->sNodeDBTable
[0].wMaxSuppRate
),
794 &(pMgmt
->sNodeDBTable
[0].wSuppRate
),
795 &(pMgmt
->sNodeDBTable
[0].byTopCCKBasicRate
),
796 &(pMgmt
->sNodeDBTable
[0].byTopOFDMBasicRate
)
798 pMgmt
->sNodeDBTable
[0].wTxDataRate
= pMgmt
->sNodeDBTable
[0].wMaxBasicRate
;
799 pMgmt
->sNodeDBTable
[0].uRatePollTimeout
= FALLBACK_POLL_SECOND
;
805 * Routine Description:
808 * Second call back function to update Node DB info & AP link status
816 void BSSvSecondCallBack(struct vnt_private
*pDevice
)
818 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
820 PWLAN_IE_SSID pItemSSID
, pCurrSSID
;
821 u32 uSleepySTACnt
= 0;
822 u32 uNonShortSlotSTACnt
= 0;
823 u32 uLongPreambleSTACnt
= 0;
825 spin_lock_irq(&pDevice
->lock
);
827 pDevice
->uAssocCount
= 0;
829 //Power Saving Mode Tx Burst
830 if ( pDevice
->bEnablePSMode
== true ) {
831 pDevice
->ulPSModeWaitTx
++;
832 if ( pDevice
->ulPSModeWaitTx
>= 2 ) {
833 pDevice
->ulPSModeWaitTx
= 0;
834 pDevice
->bPSModeTxBurst
= false;
838 pDevice
->byERPFlag
&=
839 ~(WLAN_SET_ERP_BARKER_MODE(1) | WLAN_SET_ERP_NONERP_PRESENT(1));
841 if (pDevice
->wUseProtectCntDown
> 0) {
842 pDevice
->wUseProtectCntDown
--;
845 // disable protect mode
846 pDevice
->byERPFlag
&= ~(WLAN_SET_ERP_USE_PROTECTION(1));
849 if(pDevice
->byReAssocCount
> 0) {
850 pDevice
->byReAssocCount
++;
851 if((pDevice
->byReAssocCount
> 10) && (pDevice
->bLinkPass
!= true)) { //10 sec timeout
852 printk("Re-association timeout!!!\n");
853 pDevice
->byReAssocCount
= 0;
854 // if(pDevice->bWPASuppWextEnabled == true)
856 union iwreq_data wrqu
;
857 memset(&wrqu
, 0, sizeof (wrqu
));
858 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
859 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
860 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
863 else if(pDevice
->bLinkPass
== true)
864 pDevice
->byReAssocCount
= 0;
867 pMgmt
->eLastState
= pMgmt
->eCurrState
;
869 s_uCalculateLinkQual(pDevice
);
871 for (ii
= 0; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
873 if (pMgmt
->sNodeDBTable
[ii
].bActive
) {
874 // Increase in-activity counter
875 pMgmt
->sNodeDBTable
[ii
].uInActiveCount
++;
878 if (pMgmt
->sNodeDBTable
[ii
].uInActiveCount
> MAX_INACTIVE_COUNT
) {
879 BSSvRemoveOneNode(pDevice
, ii
);
880 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
881 "Inactive timeout [%d] sec, STA index = [%d] remove\n", MAX_INACTIVE_COUNT
, ii
);
885 if (pMgmt
->sNodeDBTable
[ii
].eNodeState
>= NODE_ASSOC
) {
887 pDevice
->uAssocCount
++;
889 // check if Non ERP exist
890 if (pMgmt
->sNodeDBTable
[ii
].uInActiveCount
< ERP_RECOVER_COUNT
) {
891 if (!pMgmt
->sNodeDBTable
[ii
].bShortPreamble
) {
892 pDevice
->byERPFlag
|= WLAN_SET_ERP_BARKER_MODE(1);
893 uLongPreambleSTACnt
++;
895 if (!pMgmt
->sNodeDBTable
[ii
].bERPExist
) {
896 pDevice
->byERPFlag
|= WLAN_SET_ERP_NONERP_PRESENT(1);
897 pDevice
->byERPFlag
|= WLAN_SET_ERP_USE_PROTECTION(1);
899 if (!pMgmt
->sNodeDBTable
[ii
].bShortSlotTime
)
900 uNonShortSlotSTACnt
++;
904 // check if any STA in PS mode
905 if (pMgmt
->sNodeDBTable
[ii
].bPSEnable
)
910 // Rate fallback check
911 if (!pDevice
->bFixRate
) {
913 // ii = 0 for multicast node (AP & Adhoc)
914 RATEvTxRateFallBack((void *)pDevice
,
915 &(pMgmt
->sNodeDBTable
[ii
]));
918 // ii = 0 reserved for unicast AP node (Infra STA)
919 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
)
920 RATEvTxRateFallBack((void *)pDevice
,
921 &(pMgmt
->sNodeDBTable
[ii
]));
926 // check if pending PS queue
927 if (pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
!= 0) {
928 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Index= %d, Queue = %d pending \n",
929 ii
, pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
);
930 if ((ii
>0) && (pMgmt
->sNodeDBTable
[ii
].wEnQueueCnt
> 15)) {
931 BSSvRemoveOneNode(pDevice
, ii
);
932 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Pending many queues PS STA Index = %d remove \n", ii
);
940 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) && (pDevice
->byBBType
== BB_TYPE_11G
)) {
942 // on/off protect mode
943 if (WLAN_GET_ERP_USE_PROTECTION(pDevice
->byERPFlag
)) {
944 if (!pDevice
->bProtectMode
) {
945 MACvEnableProtectMD(pDevice
);
946 pDevice
->bProtectMode
= true;
950 if (pDevice
->bProtectMode
) {
951 MACvDisableProtectMD(pDevice
);
952 pDevice
->bProtectMode
= false;
955 // on/off short slot time
957 if (uNonShortSlotSTACnt
> 0) {
958 if (pDevice
->bShortSlotTime
) {
959 pDevice
->bShortSlotTime
= false;
960 BBvSetShortSlotTime(pDevice
);
961 vUpdateIFS((void *)pDevice
);
965 if (!pDevice
->bShortSlotTime
) {
966 pDevice
->bShortSlotTime
= true;
967 BBvSetShortSlotTime(pDevice
);
968 vUpdateIFS((void *)pDevice
);
972 // on/off barker long preamble mode
974 if (uLongPreambleSTACnt
> 0) {
975 if (!pDevice
->bBarkerPreambleMd
) {
976 MACvEnableBarkerPreambleMd(pDevice
);
977 pDevice
->bBarkerPreambleMd
= true;
981 if (pDevice
->bBarkerPreambleMd
) {
982 MACvDisableBarkerPreambleMd(pDevice
);
983 pDevice
->bBarkerPreambleMd
= false;
989 // Check if any STA in PS mode, enable DTIM multicast deliver
990 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
991 if (uSleepySTACnt
> 0)
992 pMgmt
->sNodeDBTable
[0].bPSEnable
= true;
994 pMgmt
->sNodeDBTable
[0].bPSEnable
= false;
997 pItemSSID
= (PWLAN_IE_SSID
)pMgmt
->abyDesireSSID
;
998 pCurrSSID
= (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
;
1000 if ((pMgmt
->eCurrMode
== WMAC_MODE_STANDBY
) ||
1001 (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
)) {
1003 if (pMgmt
->sNodeDBTable
[0].bActive
) { // Assoc with BSS
1005 if (pDevice
->bUpdateBBVGA
) {
1006 s_vCheckSensitivity(pDevice
);
1007 s_vCheckPreEDThreshold(pDevice
);
1010 if ((pMgmt
->sNodeDBTable
[0].uInActiveCount
>= (LOST_BEACON_COUNT
/2)) &&
1011 (pDevice
->byBBVGACurrent
!= pDevice
->abyBBVGA
[0]) ) {
1012 pDevice
->byBBVGANew
= pDevice
->abyBBVGA
[0];
1013 bScheduleCommand((void *) pDevice
,
1014 WLAN_CMD_CHANGE_BBSENSITIVITY
,
1018 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
>= LOST_BEACON_COUNT
) {
1019 pMgmt
->sNodeDBTable
[0].bActive
= false;
1020 pMgmt
->eCurrMode
= WMAC_MODE_STANDBY
;
1021 pMgmt
->eCurrState
= WMAC_STATE_IDLE
;
1022 netif_stop_queue(pDevice
->dev
);
1023 pDevice
->bLinkPass
= false;
1024 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
1025 pDevice
->bRoaming
= true;
1026 pDevice
->bIsRoaming
= false;
1028 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Lost AP beacon [%d] sec, disconnected !\n", pMgmt
->sNodeDBTable
[0].uInActiveCount
);
1029 /* let wpa supplicant know AP may disconnect */
1031 union iwreq_data wrqu
;
1032 memset(&wrqu
, 0, sizeof (wrqu
));
1033 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1034 PRINT_K("wireless_send_event--->SIOCGIWAP(disassociated)\n");
1035 wireless_send_event(pDevice
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
1039 else if (pItemSSID
->len
!= 0) {
1041 if ((pDevice
->bEnableRoaming
== true)&&(!(pMgmt
->Cisco_cckm
))) {
1042 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bRoaming %d, !\n", pDevice
->bRoaming
);
1043 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"bIsRoaming %d, !\n", pDevice
->bIsRoaming
);
1044 if ((pDevice
->bRoaming
== true)&&(pDevice
->bIsRoaming
== true)){
1045 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Fast Roaming ...\n");
1046 BSSvClearBSSList((void *) pDevice
, pDevice
->bLinkPass
);
1047 bScheduleCommand((void *) pDevice
,
1048 WLAN_CMD_BSSID_SCAN
,
1049 pMgmt
->abyDesireSSID
);
1050 bScheduleCommand((void *) pDevice
,
1052 pMgmt
->abyDesireSSID
);
1053 pDevice
->uAutoReConnectTime
= 0;
1054 pDevice
->uIsroamingTime
= 0;
1055 pDevice
->bRoaming
= false;
1057 else if ((pDevice
->bRoaming
== false)&&(pDevice
->bIsRoaming
== true)) {
1058 pDevice
->uIsroamingTime
++;
1059 if (pDevice
->uIsroamingTime
>= 20)
1060 pDevice
->bIsRoaming
= false;
1065 if (pDevice
->uAutoReConnectTime
< 10) {
1066 pDevice
->uAutoReConnectTime
++;
1067 //network manager support need not do Roaming scan???
1068 if(pDevice
->bWPASuppWextEnabled
==true)
1069 pDevice
->uAutoReConnectTime
= 0;
1072 //mike use old encryption status for wpa reauthen
1073 if(pDevice
->bWPADEVUp
)
1074 pDevice
->eEncryptionStatus
= pDevice
->eOldEncryptionStatus
;
1076 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Roaming ...\n");
1077 BSSvClearBSSList((void *) pDevice
, pDevice
->bLinkPass
);
1078 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
1079 bScheduleCommand((void *) pDevice
,
1080 WLAN_CMD_BSSID_SCAN
,
1081 pMgmt
->abyDesireSSID
);
1082 bScheduleCommand((void *) pDevice
,
1084 pMgmt
->abyDesireSSID
);
1085 pDevice
->uAutoReConnectTime
= 0;
1091 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
1092 // if adhoc started which essid is NULL string, rescanning.
1093 if ((pMgmt
->eCurrState
== WMAC_STATE_STARTED
) && (pCurrSSID
->len
== 0)) {
1094 if (pDevice
->uAutoReConnectTime
< 10) {
1095 pDevice
->uAutoReConnectTime
++;
1098 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Adhoc re-scanning ...\n");
1099 pMgmt
->eScanType
= WMAC_SCAN_ACTIVE
;
1100 bScheduleCommand((void *) pDevice
, WLAN_CMD_BSSID_SCAN
, NULL
);
1101 bScheduleCommand((void *) pDevice
, WLAN_CMD_SSID
, NULL
);
1102 pDevice
->uAutoReConnectTime
= 0;
1105 if (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
) {
1107 if (pDevice
->bUpdateBBVGA
) {
1108 s_vCheckSensitivity(pDevice
);
1109 s_vCheckPreEDThreshold(pDevice
);
1111 if (pMgmt
->sNodeDBTable
[0].uInActiveCount
>=ADHOC_LOST_BEACON_COUNT
) {
1112 DBG_PRT(MSG_LEVEL_NOTICE
, KERN_INFO
"Lost other STA beacon [%d] sec, started !\n", pMgmt
->sNodeDBTable
[0].uInActiveCount
);
1113 pMgmt
->sNodeDBTable
[0].uInActiveCount
= 0;
1114 pMgmt
->eCurrState
= WMAC_STATE_STARTED
;
1115 netif_stop_queue(pDevice
->dev
);
1116 pDevice
->bLinkPass
= false;
1117 ControlvMaskByte(pDevice
,MESSAGE_REQUEST_MACREG
,MAC_REG_PAPEDELAY
,LEDSTS_STS
,LEDSTS_SLOW
);
1122 if (pDevice
->bLinkPass
== true) {
1123 if (netif_queue_stopped(pDevice
->dev
))
1124 netif_wake_queue(pDevice
->dev
);
1127 spin_unlock_irq(&pDevice
->lock
);
1129 pMgmt
->sTimerSecondCallback
.expires
= RUN_AT(HZ
);
1130 add_timer(&pMgmt
->sTimerSecondCallback
);
1135 * Routine Description:
1138 * Update Tx attemps, Tx failure counter in Node DB
1146 void BSSvUpdateNodeTxCounter(struct vnt_private
*pDevice
,
1147 PSStatCounter pStatistic
, u8 byTSR
, u8 byPktNO
)
1149 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1153 u16 wFallBackRate
= RATE_1M
;
1160 byPktNum
= (byPktNO
& 0x0F) >> 4;
1161 byTxRetry
= (byTSR
& 0xF0) >> 4;
1162 wRate
= (u16
) (byPktNO
& 0xF0) >> 4;
1163 wFIFOCtl
= pStatistic
->abyTxPktInfo
[byPktNum
].wFIFOCtl
;
1164 pbyDestAddr
= (u8
*) &( pStatistic
->abyTxPktInfo
[byPktNum
].abyDestAddr
[0]);
1166 if (wFIFOCtl
& FIFOCTL_AUTO_FB_0
) {
1167 byFallBack
= AUTO_FB_0
;
1168 } else if (wFIFOCtl
& FIFOCTL_AUTO_FB_1
) {
1169 byFallBack
= AUTO_FB_1
;
1171 byFallBack
= AUTO_FB_NONE
;
1174 // Only Unicast using support rates
1175 if (wFIFOCtl
& FIFOCTL_NEEDACK
) {
1176 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) {
1177 pMgmt
->sNodeDBTable
[0].uTxAttempts
+= 1;
1178 if ( !(byTSR
& (TSR_TMO
| TSR_RETRYTMO
))) {
1179 // transmit success, TxAttempts at least plus one
1180 pMgmt
->sNodeDBTable
[0].uTxOk
[MAX_RATE
]++;
1181 if ( (byFallBack
== AUTO_FB_NONE
) ||
1182 (wRate
< RATE_18M
) ) {
1183 wFallBackRate
= wRate
;
1184 } else if (byFallBack
== AUTO_FB_0
) {
1186 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][byTxRetry
];
1188 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][4];
1189 } else if (byFallBack
== AUTO_FB_1
) {
1191 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][byTxRetry
];
1193 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][4];
1195 pMgmt
->sNodeDBTable
[0].uTxOk
[wFallBackRate
]++;
1197 pMgmt
->sNodeDBTable
[0].uTxFailures
++;
1199 pMgmt
->sNodeDBTable
[0].uTxRetry
+= byTxRetry
;
1200 if (byTxRetry
!= 0) {
1201 pMgmt
->sNodeDBTable
[0].uTxFail
[MAX_RATE
]+=byTxRetry
;
1202 if ( (byFallBack
== AUTO_FB_NONE
) ||
1203 (wRate
< RATE_18M
) ) {
1204 pMgmt
->sNodeDBTable
[0].uTxFail
[wRate
]+=byTxRetry
;
1205 } else if (byFallBack
== AUTO_FB_0
) {
1206 for (ii
= 0; ii
< byTxRetry
; ii
++) {
1209 awHWRetry0
[wRate
-RATE_18M
][ii
];
1212 awHWRetry0
[wRate
-RATE_18M
][4];
1213 pMgmt
->sNodeDBTable
[0].uTxFail
[wFallBackRate
]++;
1215 } else if (byFallBack
== AUTO_FB_1
) {
1216 for (ii
= 0; ii
< byTxRetry
; ii
++) {
1219 awHWRetry1
[wRate
-RATE_18M
][ii
];
1222 awHWRetry1
[wRate
-RATE_18M
][4];
1223 pMgmt
->sNodeDBTable
[0].uTxFail
[wFallBackRate
]++;
1229 if ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) ||
1230 (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
)) {
1232 if (BSSbIsSTAInNodeDB((void *) pDevice
,
1235 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxAttempts
+= 1;
1236 if ( !(byTSR
& (TSR_TMO
| TSR_RETRYTMO
))) {
1237 // transmit success, TxAttempts at least plus one
1238 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxOk
[MAX_RATE
]++;
1239 if ( (byFallBack
== AUTO_FB_NONE
) ||
1240 (wRate
< RATE_18M
) ) {
1241 wFallBackRate
= wRate
;
1242 } else if (byFallBack
== AUTO_FB_0
) {
1244 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][byTxRetry
];
1246 wFallBackRate
= awHWRetry0
[wRate
-RATE_18M
][4];
1247 } else if (byFallBack
== AUTO_FB_1
) {
1249 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][byTxRetry
];
1251 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][4];
1253 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxOk
[wFallBackRate
]++;
1255 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxFailures
++;
1257 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxRetry
+= byTxRetry
;
1258 if (byTxRetry
!= 0) {
1259 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxFail
[MAX_RATE
]+=byTxRetry
;
1260 if ( (byFallBack
== AUTO_FB_NONE
) ||
1261 (wRate
< RATE_18M
) ) {
1262 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxFail
[wRate
]+=byTxRetry
;
1263 } else if (byFallBack
== AUTO_FB_0
) {
1264 for (ii
= 0; ii
< byTxRetry
; ii
++) {
1267 awHWRetry0
[wRate
-RATE_18M
][ii
];
1270 awHWRetry0
[wRate
-RATE_18M
][4];
1271 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxFail
[wFallBackRate
]++;
1273 } else if (byFallBack
== AUTO_FB_1
) {
1274 for (ii
= 0; ii
< byTxRetry
; ii
++) {
1276 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][ii
];
1278 wFallBackRate
= awHWRetry1
[wRate
-RATE_18M
][4];
1279 pMgmt
->sNodeDBTable
[uNodeIndex
].uTxFail
[wFallBackRate
]++;
1290 * Routine Description:
1291 * Clear Nodes & skb in DB Table
1296 * hDeviceContext - The adapter context.
1297 * uStartIndex - starting index
1306 void BSSvClearNodeDBTable(struct vnt_private
*pDevice
, u32 uStartIndex
)
1308 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1309 struct sk_buff
*skb
;
1312 for (ii
= uStartIndex
; ii
< (MAX_NODE_NUM
+ 1); ii
++) {
1313 if (pMgmt
->sNodeDBTable
[ii
].bActive
) {
1314 // check if sTxPSQueue has been initial
1315 if (pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
.next
!= NULL
) {
1316 while ((skb
= skb_dequeue(&pMgmt
->sNodeDBTable
[ii
].sTxPSQueue
)) != NULL
){
1317 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"PS skb != NULL %d\n", ii
);
1321 memset(&pMgmt
->sNodeDBTable
[ii
], 0, sizeof(KnownNodeDB
));
1326 static void s_vCheckSensitivity(struct vnt_private
*pDevice
)
1328 PKnownBSS pBSSList
= NULL
;
1329 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1332 if ((pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) ||
1333 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))) {
1334 pBSSList
= BSSpAddrIsInBSSList(pDevice
, pMgmt
->abyCurrBSSID
, (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
);
1335 if (pBSSList
!= NULL
) {
1336 /* Update BB register if RSSI is too strong */
1337 signed long LocalldBmAverage
= 0;
1338 signed long uNumofdBm
= 0;
1339 for (ii
= 0; ii
< RSSI_STAT_COUNT
; ii
++) {
1340 if (pBSSList
->ldBmAverage
[ii
] != 0) {
1342 LocalldBmAverage
+= pBSSList
->ldBmAverage
[ii
];
1345 if (uNumofdBm
> 0) {
1346 LocalldBmAverage
= LocalldBmAverage
/uNumofdBm
;
1347 for (ii
=0;ii
<BB_VGA_LEVEL
;ii
++) {
1348 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"LocalldBmAverage:%ld, %ld %02x\n", LocalldBmAverage
, pDevice
->ldBmThreshold
[ii
], pDevice
->abyBBVGA
[ii
]);
1349 if (LocalldBmAverage
< pDevice
->ldBmThreshold
[ii
]) {
1350 pDevice
->byBBVGANew
= pDevice
->abyBBVGA
[ii
];
1354 if (pDevice
->byBBVGANew
!= pDevice
->byBBVGACurrent
) {
1355 pDevice
->uBBVGADiffCount
++;
1356 if (pDevice
->uBBVGADiffCount
>= BB_VGA_CHANGE_THRESHOLD
)
1357 bScheduleCommand(pDevice
,
1358 WLAN_CMD_CHANGE_BBSENSITIVITY
,
1361 pDevice
->uBBVGADiffCount
= 0;
1368 static void s_uCalculateLinkQual(struct vnt_private
*pDevice
)
1370 unsigned long TxOkRatio
, TxCnt
;
1371 unsigned long RxOkRatio
, RxCnt
;
1372 unsigned long RssiRatio
;
1375 TxCnt
= pDevice
->scStatistic
.TxNoRetryOkCount
+
1376 pDevice
->scStatistic
.TxRetryOkCount
+
1377 pDevice
->scStatistic
.TxFailCount
;
1378 RxCnt
= pDevice
->scStatistic
.RxFcsErrCnt
+
1379 pDevice
->scStatistic
.RxOkCnt
;
1380 TxOkRatio
= (TxCnt
< 6) ? 4000:((pDevice
->scStatistic
.TxNoRetryOkCount
* 4000) / TxCnt
);
1381 RxOkRatio
= (RxCnt
< 6) ? 2000:((pDevice
->scStatistic
.RxOkCnt
* 2000) / RxCnt
);
1382 //decide link quality
1383 if(pDevice
->bLinkPass
!=true)
1385 pDevice
->scStatistic
.LinkQuality
= 0;
1386 pDevice
->scStatistic
.SignalStren
= 0;
1390 RFvRSSITodBm(pDevice
, (u8
)(pDevice
->uCurrRSSI
), &ldBm
);
1394 else if(-ldBm
> 90) {
1398 RssiRatio
= (40-(-ldBm
-50))*4000/40;
1400 pDevice
->scStatistic
.SignalStren
= RssiRatio
/40;
1401 pDevice
->scStatistic
.LinkQuality
= (RssiRatio
+TxOkRatio
+RxOkRatio
)/100;
1403 pDevice
->scStatistic
.RxFcsErrCnt
= 0;
1404 pDevice
->scStatistic
.RxOkCnt
= 0;
1405 pDevice
->scStatistic
.TxFailCount
= 0;
1406 pDevice
->scStatistic
.TxNoRetryOkCount
= 0;
1407 pDevice
->scStatistic
.TxRetryOkCount
= 0;
1410 void BSSvClearAnyBSSJoinRecord(struct vnt_private
*pDevice
)
1412 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1415 for (ii
= 0; ii
< MAX_BSS_NUM
; ii
++)
1416 pMgmt
->sBSSList
[ii
].bSelected
= false;
1421 static void s_vCheckPreEDThreshold(struct vnt_private
*pDevice
)
1423 PKnownBSS pBSSList
= NULL
;
1424 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1426 if ((pMgmt
->eCurrState
== WMAC_STATE_ASSOC
) ||
1427 ((pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) && (pMgmt
->eCurrState
== WMAC_STATE_JOINTED
))) {
1428 pBSSList
= BSSpAddrIsInBSSList(pDevice
, pMgmt
->abyCurrBSSID
, (PWLAN_IE_SSID
)pMgmt
->abyCurrSSID
);
1429 if (pBSSList
!= NULL
) {
1430 pDevice
->byBBPreEDRSSI
= (u8
) (~(pBSSList
->ldBmAverRange
) + 1);
1431 BBvUpdatePreEDThreshold(pDevice
, false);