6 #define RATE_ADAPTIVE_TIMER_PERIOD 300
41 char OfdmTxPwrIdx, CckTxPwrIdx;
46 HiPwrUpperTh = HiPwrUpperTh * 10;
47 HiPwrLowerTh = HiPwrLowerTh * 10;
63 if (CckTxPwrIdx == u1bTmp) {
64 u1bTmp = (u1bTmp > 16) ? (u1bTmp -16): 0;
68 u1bTmp = (u1bTmp > 16) ? (u1bTmp -16): 0;
78 if (u1bTmp < CckTxPwrIdx) {
83 if (u1bTmp < OfdmTxPwrIdx) {
131 u16 CCKFalseAlarm, OFDMFalseAlarm;
132 u16 OfdmFA1, OfdmFA2;
133 int InitialGainStep = 7;
134 int LowestGainStage = 4;
135 u32 AwakePeriodIn2Sec = 0;
154 if (AwakePeriodIn2Sec) {
155 OfdmFA1 = (
u16)((OfdmFA1 * AwakePeriodIn2Sec) / 2000) ;
156 OfdmFA2 = (
u16)((OfdmFA2 * AwakePeriodIn2Sec) / 2000) ;
165 if (OFDMFalseAlarm > OfdmFA1) {
166 if (OFDMFalseAlarm > OfdmFA2) {
232 unsigned short Found = 0;
233 u8 NaiveTxRate = TxRate&RateMask;
235 rate_len = priv->
ieee80211->current_network.rates_len;
236 rate_ex_len = priv->
ieee80211->current_network.rates_ex_len;
237 for (idx=0; idx < rate_len; idx++) {
238 if ((priv->
ieee80211->current_network.rates[idx] & RateMask) == NaiveTxRate) {
243 for (idx = 0; idx < rate_ex_len; idx++) {
244 if ((priv->
ieee80211->current_network.rates_ex[idx] & RateMask) == NaiveTxRate) {
302 printk(
"GetUpgradeTxRate(): Input Tx Rate(%d) is undefined!\n", rate);
362 printk(
"GetDegradeTxRate(): Input Tx Rate(%d) is undefined!\n", rate);
380 bool bReturn =
false;
382 if ((rate <= 22) && (rate != 12) && (rate != 18)) {
395 u8 tmpu1Byte, CurrentThermal, Idx;
396 char CckTxPwrIdx, OfdmTxPwrIdx;
399 CurrentThermal = (tmpu1Byte & 0xf0) >> 4;
400 CurrentThermal = (CurrentThermal > 0x0c) ? 0x0c:CurrentThermal;
404 for (Idx = 1; Idx < 15; Idx++) {
405 CckTxPwrIdx = priv->
chtxpwr[Idx];
410 CckTxPwrIdx += (CurrentThermal - priv->
ThermalMeter) * 2;
411 OfdmTxPwrIdx += (CurrentThermal - priv->
ThermalMeter) * 2;
413 if (CckTxPwrIdx > 35)
415 if (OfdmTxPwrIdx > 35)
419 CckTxPwrIdx -= (priv->
ThermalMeter - CurrentThermal) * 2;
420 OfdmTxPwrIdx -= (priv->
ThermalMeter - CurrentThermal) * 2;
424 if (OfdmTxPwrIdx < 0)
429 priv->
chtxpwr[Idx] = CckTxPwrIdx;
441 unsigned long CurrTxokCnt;
444 unsigned long CurrRxokCnt;
446 bool bTryDown =
false;
450 long CurrSignalStrength;
451 bool bUpdateInitialGain =
false;
452 u8 u1bOfdm = 0, u1bCck = 0;
453 char OfdmTxPwrIdx, CckTxPwrIdx;
466 if (CurrTxokCnt > 0) {
467 CurrRetryRate = (
u16)(CurrRetryCnt * 100 / CurrTxokCnt);
470 CurrRetryRate = (
u16)(CurrRetryCnt * 100 / 1);
479 if (CurrRetryRate == 0 && CurrTxokCnt == 0) {
543 }
else if (CurrSignalStrength > -47 && (CurrRetryRate < 50)) {
558 }
else if (CurrTxokCnt > 9 && CurrTxokCnt < 100 && CurrRetryRate >= 600) {
574 else if ((CurrRetryRate > 17) && (priv->
LastRetryRate > 16) && (CurrSignalStrength > -72)) {
578 if (bTryDown && (CurrSignalStrength < -75))
586 }
else if (((CurrRetryRate > 21) && (priv->
LastRetryRate > 20)) && (CurrSignalStrength > -74)) {
592 }
else if ((CurrRetryRate < 8) && (priv->
LastRetryRate < 8)) {
596 if (bTryDown && (CurrSignalStrength < -75)){
607 }
else if ((CurrRetryRate < 15) && (priv->
LastRetryRate < 16)) {
611 if (bTryDown && (CurrSignalStrength < -80))
619 }
else if (((CurrRetryRate > 33) && (priv->
LastRetryRate > 32)) && (CurrSignalStrength > -82)) {
624 }
else if ((CurrRetryRate < 20) && (priv->
LastRetryRate < 21)) {
628 if (bTryDown && (CurrSignalStrength < -82))
637 }
else if ((CurrRetryRate < 22) && (priv->
LastRetryRate < 23)) {
642 if (CurrRetryRate > 95) {
645 else if ((CurrRetryRate < 29) && (priv->
LastRetryRate < 30)) {
650 if (CurrRetryRate > 149) {
652 }
else if ((CurrRetryRate < 60) && (priv->
LastRetryRate < 65)) {
659 }
else if ((CurrRetryRate < 65) && (priv->
LastRetryRate < 70)) {
669 if (bTryUp && bTryDown)
670 printk(
"StaRateAdaptive87B(): Tx Rate tried upping and downing simultaneously!\n");
678 if (
jiffies % (CurrRetryRate + 101) == 0) {
703 bUpdateInitialGain =
true;
776 bUpdateInitialGain =
true;
803 if (u1bCck == CckTxPwrIdx) {
804 if (u1bOfdm != (OfdmTxPwrIdx + 2)) {
806 u1bOfdm = ((u1bOfdm + 2) > 35) ? 35: (u1bOfdm + 2);
809 }
else if (u1bCck < CckTxPwrIdx) {
813 u1bOfdm = ((u1bOfdm + 2) > 35) ? 35: (u1bOfdm + 2);
822 if (u1bCck == CckTxPwrIdx) {
827 else if (u1bCck < CckTxPwrIdx) {
829 u1bOfdm = ((u1bOfdm - 2) > 0) ? (u1bOfdm - 2): 0;
839 if (bUpdateInitialGain) {
844 if (CurrSignalStrength < -85)
917 bool bAntennaSwitched =
false;
919 switch (u1bAntennaIndex) {
927 bAntennaSwitched =
true;
937 bAntennaSwitched =
true;
942 printk(
"SetAntenna8185: unknown u1bAntennaIndex(%d)\n", u1bAntennaIndex);
949 return bAntennaSwitched;
974 bool bSwCheckSS =
false;
978 printk(
"(1) AdTickCount: %d, AdCheckPeriod: %d\n",
980 printk(
"(2) AdRxSignalStrength: %ld, AdRxSsThreshold: %ld\n",