2013-05-08 21:45:39 +00:00
|
|
|
/*++
|
|
|
|
Copyright (c) Realtek Semiconductor Corp. All rights reserved.
|
|
|
|
|
|
|
|
Module Name:
|
|
|
|
RateAdaptive.c
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
Abstract:
|
|
|
|
Implement Rate Adaptive functions for common operations.
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
Major Change History:
|
|
|
|
When Who What
|
2013-05-19 04:28:07 +00:00
|
|
|
---------- --------------- -------------------------------
|
|
|
|
2011-08-12 Page Create.
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
--*/
|
|
|
|
#include "odm_precomp.h"
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Rate adaptive parameters */
|
|
|
|
|
|
|
|
static u1Byte RETRY_PENALTY[PERENTRY][RETRYSIZE+1] = {
|
|
|
|
{5,4,3,2,0,3},/* 92 , idx=0 */
|
|
|
|
{6,5,4,3,0,4},/* 86 , idx=1 */
|
|
|
|
{6,5,4,2,0,4},/* 81 , idx=2 */
|
|
|
|
{8,7,6,4,0,6},/* 75 , idx=3 */
|
|
|
|
{10,9,8,6,0,8},/* 71 , idx=4 */
|
|
|
|
{10,9,8,4,0,8},/* 66 , idx=5 */
|
|
|
|
{10,9,8,2,0,8},/* 62 , idx=6 */
|
|
|
|
{10,9,8,0,0,8},/* 59 , idx=7 */
|
|
|
|
{18,17,16,8,0,16},/* 53 , idx=8 */
|
|
|
|
{26,25,24,16,0,24},/* 50 , idx=9 */
|
|
|
|
{34,33,32,24,0,32},/* 47 , idx=0x0a */
|
|
|
|
{34,31,28,20,0,32},/* 43 , idx=0x0b */
|
|
|
|
{34,31,27,18,0,32},/* 40 , idx=0x0c */
|
|
|
|
{34,31,26,16,0,32},/* 37 , idx=0x0d */
|
|
|
|
{34,30,22,16,0,32},/* 32 , idx=0x0e */
|
|
|
|
{34,30,24,16,0,32},/* 26 , idx=0x0f */
|
|
|
|
{49,46,40,16,0,48},/* 20 , idx=0x10 */
|
|
|
|
{49,45,32,0,0,48},/* 17 , idx=0x11 */
|
|
|
|
{49,45,22,18,0,48},/* 15 , idx=0x12 */
|
|
|
|
{49,40,24,16,0,48},/* 12 , idx=0x13 */
|
|
|
|
{49,32,18,12,0,48},/* 9 , idx=0x14 */
|
|
|
|
{49,22,18,14,0,48},/* 6 , idx=0x15 */
|
|
|
|
{49,16,16,0,0,48}};/* 3, idx=0x16 */
|
|
|
|
|
|
|
|
static u1Byte RETRY_PENALTY_UP[RETRYSIZE+1]={49,44,16,16,0,48}; /* 12% for rate up */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
static u1Byte PT_PENALTY[RETRYSIZE+1]={34,31,30,24,0,32};
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* wilson modify */
|
|
|
|
static u1Byte RETRY_PENALTY_IDX[2][RATESIZE] = {
|
|
|
|
{4,4,4,5,4,4,5,7,7,7,8,0x0a, /* SS>TH */
|
|
|
|
4,4,4,4,6,0x0a,0x0b,0x0d,
|
|
|
|
5,5,7,7,8,0x0b,0x0d,0x0f}, /* 0329 R01 */
|
|
|
|
{0x0a,0x0a,0x0b,0x0c,0x0a,
|
|
|
|
0x0a,0x0b,0x0c,0x0d,0x10,0x13,0x14, /* SS<TH */
|
|
|
|
0x0b,0x0c,0x0d,0x0e,0x0f,0x11,0x13,0x15,
|
|
|
|
9,9,9,9,0x0c,0x0e,0x11,0x13}};
|
|
|
|
|
|
|
|
static u1Byte RETRY_PENALTY_UP_IDX[RATESIZE] = {
|
|
|
|
0x0c,0x0d,0x0d,0x0f,0x0d,0x0e,
|
|
|
|
0x0f,0x0f,0x10,0x12,0x13,0x14, /* SS>TH */
|
|
|
|
0x0f,0x10,0x10,0x12,0x12,0x13,0x14,0x15,
|
|
|
|
0x11,0x11,0x12,0x13,0x13,0x13,0x14,0x15};
|
|
|
|
|
|
|
|
static u1Byte RSSI_THRESHOLD[RATESIZE] = {
|
|
|
|
0,0,0,0,
|
|
|
|
0,0,0,0,0,0x24,0x26,0x2a,
|
|
|
|
0x18,0x1a,0x1d,0x1f,0x21,0x27,0x29,0x2a,
|
|
|
|
0,0,0,0x1f,0x23,0x28,0x2a,0x2c};
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
static u2Byte N_THRESHOLD_HIGH[RATESIZE] = {
|
|
|
|
4,4,8,16,
|
|
|
|
24,36,48,72,96,144,192,216,
|
|
|
|
60,80,100,160,240,400,560,640,
|
|
|
|
300,320,480,720,1000,1200,1600,2000};
|
|
|
|
static u2Byte N_THRESHOLD_LOW[RATESIZE] = {
|
|
|
|
2,2,4,8,
|
|
|
|
12,18,24,36,48,72,96,108,
|
|
|
|
30,40,50,80,120,200,280,320,
|
|
|
|
150,160,240,360,500,600,800,1000};
|
|
|
|
static u1Byte TRYING_NECESSARY[RATESIZE] = {
|
|
|
|
2,2,2,2,
|
|
|
|
2,2,3,3,4,4,5,7,
|
|
|
|
4,4,7,10,10,12,12,18,
|
|
|
|
5,7,7,8,11,18,36,60}; /* 0329 1207 */
|
|
|
|
|
|
|
|
static u1Byte DROPING_NECESSARY[RATESIZE] = {
|
|
|
|
1,1,1,1,
|
|
|
|
1,2,3,4,5,6,7,8,
|
|
|
|
1,2,3,4,5,6,7,8,
|
|
|
|
5,6,7,8,9,10,11,12};
|
|
|
|
|
|
|
|
static u4Byte INIT_RATE_FALLBACK_TABLE[16]={
|
|
|
|
0x0f8ff015, /* 0: 40M BGN mode */
|
|
|
|
0x0f8ff010, /* 1: 40M GN mode */
|
|
|
|
0x0f8ff005, /* 2: BN mode/ 40M BGN mode */
|
|
|
|
0x0f8ff000, /* 3: N mode */
|
|
|
|
0x00000ff5, /* 4: BG mode */
|
|
|
|
0x00000ff0, /* 5: G mode */
|
|
|
|
0x0000000d, /* 6: B mode */
|
|
|
|
0, /* 7: */
|
|
|
|
0, /* 8: */
|
|
|
|
0, /* 9: */
|
|
|
|
0, /* 10: */
|
|
|
|
0, /* 11: */
|
|
|
|
0, /* 12: */
|
|
|
|
0, /* 13: */
|
|
|
|
0, /* 14: */
|
|
|
|
0, /* 15: */
|
2013-05-08 21:45:39 +00:00
|
|
|
};
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
static u1Byte PendingForRateUpFail[5] = {2,10,24,40,60};
|
|
|
|
static u2Byte DynamicTxRPTTiming[6] = {
|
|
|
|
0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12 ,0x927c}; /* 200ms-1200ms */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* End Rate adaptive parameters */
|
|
|
|
|
|
|
|
static void odm_SetTxRPTTiming_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct * pDM_Odm,
|
|
|
|
struct odm_ra_info *pRaInfo,
|
2013-07-10 18:25:07 +00:00
|
|
|
u1Byte extend
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
u1Byte idx = 0;
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
for (idx=0; idx<5; idx++)
|
|
|
|
if (DynamicTxRPTTiming[idx] == pRaInfo->RptTime)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
if (extend==0) /* back to default timing */
|
|
|
|
idx=0; /* 200ms */
|
|
|
|
else if (extend==1) {/* increase the timing */
|
2013-05-08 21:45:39 +00:00
|
|
|
idx+=1;
|
|
|
|
if (idx>5)
|
|
|
|
idx=5;
|
|
|
|
}
|
2013-07-10 18:25:07 +00:00
|
|
|
else if (extend==2) {/* decrease the timing */
|
2013-05-09 04:04:25 +00:00
|
|
|
if (idx!=0)
|
2013-05-08 21:45:39 +00:00
|
|
|
idx-=1;
|
|
|
|
}
|
|
|
|
pRaInfo->RptTime=DynamicTxRPTTiming[idx];
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("pRaInfo->RptTime=0x%x\n", pRaInfo->RptTime));
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
static int odm_RateDown_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct *pDM_Odm,
|
|
|
|
struct odm_ra_info *pRaInfo
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
u1Byte RateID, LowestRate, HighestRate;
|
|
|
|
u1Byte i;
|
|
|
|
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDown_8188E()\n"));
|
2013-05-09 04:04:25 +00:00
|
|
|
if (NULL == pRaInfo)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateDown_8188E(): pRaInfo is NULL\n"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
RateID = pRaInfo->PreRate;
|
|
|
|
LowestRate = pRaInfo->LowestRate;
|
|
|
|
HighestRate = pRaInfo->HighestRate;
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
|
|
|
|
(" RateID=%d LowestRate=%d HighestRate=%d RateSGI=%d\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
RateID, LowestRate, HighestRate, pRaInfo->RateSGI));
|
2013-07-10 18:25:07 +00:00
|
|
|
if (RateID > HighestRate) {
|
2013-05-08 21:45:39 +00:00
|
|
|
RateID=HighestRate;
|
2013-07-10 18:25:07 +00:00
|
|
|
} else if (pRaInfo->RateSGI) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->RateSGI=0;
|
2013-07-10 18:25:07 +00:00
|
|
|
} else if (RateID > LowestRate) {
|
|
|
|
if (RateID > 0) {
|
|
|
|
for (i=RateID-1; i>LowestRate;i--) {
|
|
|
|
if (pRaInfo->RAUseRate & BIT(i)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
RateID=i;
|
|
|
|
goto RateDownFinish;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-10 18:25:07 +00:00
|
|
|
} else if (RateID <= LowestRate) {
|
2013-05-08 21:45:39 +00:00
|
|
|
RateID = LowestRate;
|
|
|
|
}
|
|
|
|
RateDownFinish:
|
|
|
|
if (pRaInfo->RAWaitingCounter==1){
|
|
|
|
pRaInfo->RAWaitingCounter+=1;
|
|
|
|
pRaInfo->RAPendingCounter+=1;
|
2013-07-10 18:25:07 +00:00
|
|
|
} else if (pRaInfo->RAWaitingCounter==0){
|
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->RAWaitingCounter=0;
|
|
|
|
pRaInfo->RAPendingCounter=0;
|
|
|
|
}
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pRaInfo->RAPendingCounter>=4)
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->RAPendingCounter=4;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->DecisionRate=RateID;
|
|
|
|
odm_SetTxRPTTiming_8188E(pDM_Odm,pRaInfo, 2);
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down, RPT Timing default\n"));
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d",pRaInfo->RAWaitingCounter,pRaInfo->RAPendingCounter));
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down to RateID %d RateSGI %d\n", RateID, pRaInfo->RateSGI));
|
2013-05-09 04:09:18 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<=====odm_RateDown_8188E()\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
static int odm_RateUp_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct * pDM_Odm,
|
|
|
|
struct odm_ra_info *pRaInfo
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
u1Byte RateID, HighestRate;
|
|
|
|
u1Byte i;
|
|
|
|
|
2013-05-09 04:09:18 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateUp_8188E()\n"));
|
2013-07-10 18:25:07 +00:00
|
|
|
if (NULL == pRaInfo) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E(): pRaInfo is NULL\n"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
RateID = pRaInfo->PreRate;
|
|
|
|
HighestRate = pRaInfo->HighestRate;
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
|
|
|
|
(" RateID=%d HighestRate=%d\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
RateID, HighestRate));
|
|
|
|
if (pRaInfo->RAWaitingCounter==1){
|
|
|
|
pRaInfo->RAWaitingCounter=0;
|
|
|
|
pRaInfo->RAPendingCounter=0;
|
2013-07-10 18:25:07 +00:00
|
|
|
} else if (pRaInfo->RAWaitingCounter>1){
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->PreRssiStaRA=pRaInfo->RssiStaRA;
|
|
|
|
goto RateUpfinish;
|
|
|
|
}
|
|
|
|
odm_SetTxRPTTiming_8188E(pDM_Odm,pRaInfo, 0);
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E():Decrease RPT Timing\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
if (RateID < HighestRate) {
|
|
|
|
for (i=RateID+1; i<=HighestRate; i++) {
|
|
|
|
if (pRaInfo->RAUseRate & BIT(i)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
RateID=i;
|
|
|
|
goto RateUpfinish;
|
|
|
|
}
|
|
|
|
}
|
2013-07-10 18:25:07 +00:00
|
|
|
} else if (RateID == HighestRate) {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pRaInfo->SGIEnable && (pRaInfo->RateSGI != 1))
|
|
|
|
pRaInfo->RateSGI = 1;
|
2013-05-09 04:04:25 +00:00
|
|
|
else if ((pRaInfo->SGIEnable) !=1 )
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->RateSGI = 0;
|
2013-07-10 18:25:07 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
RateID = HighestRate;
|
|
|
|
}
|
|
|
|
RateUpfinish:
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pRaInfo->RAWaitingCounter==(4+PendingForRateUpFail[pRaInfo->RAPendingCounter]))
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->RAWaitingCounter=0;
|
|
|
|
else
|
|
|
|
pRaInfo->RAWaitingCounter++;
|
|
|
|
|
|
|
|
pRaInfo->DecisionRate=RateID;
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate up to RateID %d\n", RateID));
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d",pRaInfo->RAWaitingCounter,pRaInfo->RAPendingCounter));
|
2013-05-09 04:09:18 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<=====odm_RateUp_8188E()\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-26 16:20:42 +00:00
|
|
|
static void odm_ResetRaCounter_8188E(struct odm_ra_info *pRaInfo){
|
2013-05-08 21:45:39 +00:00
|
|
|
u1Byte RateID;
|
|
|
|
RateID=pRaInfo->DecisionRate;
|
|
|
|
pRaInfo->NscUp=(N_THRESHOLD_HIGH[RateID]+N_THRESHOLD_LOW[RateID])>>1;
|
|
|
|
pRaInfo->NscDown=(N_THRESHOLD_HIGH[RateID]+N_THRESHOLD_LOW[RateID])>>1;
|
|
|
|
}
|
|
|
|
|
2013-07-26 16:20:42 +00:00
|
|
|
static void odm_RateDecision_8188E(struct odm_dm_struct * pDM_Odm,
|
|
|
|
struct odm_ra_info *pRaInfo
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
u1Byte RateID = 0, RtyPtID = 0, PenaltyID1 = 0, PenaltyID2 = 0;
|
2013-07-10 18:25:07 +00:00
|
|
|
/* u4Byte pool_retry; */
|
2013-05-08 21:45:39 +00:00
|
|
|
static u1Byte DynamicTxRPTTimingCounter=0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 04:09:18 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDecision_8188E()\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) /* STA used and data packet exits */
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
if ( (pRaInfo->RssiStaRA<(pRaInfo->PreRssiStaRA-3))|| (pRaInfo->RssiStaRA>(pRaInfo->PreRssiStaRA+3))){
|
|
|
|
pRaInfo->RAWaitingCounter=0;
|
|
|
|
pRaInfo->RAPendingCounter=0;
|
|
|
|
}
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Start RA decision */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pRaInfo->PreRate > pRaInfo->HighestRate)
|
|
|
|
RateID = pRaInfo->HighestRate;
|
2013-05-19 04:28:07 +00:00
|
|
|
else
|
2013-05-08 21:45:39 +00:00
|
|
|
RateID = pRaInfo->PreRate;
|
|
|
|
if (pRaInfo->RssiStaRA > RSSI_THRESHOLD[RateID])
|
|
|
|
RtyPtID=0;
|
|
|
|
else
|
|
|
|
RtyPtID=1;
|
2013-07-10 18:25:07 +00:00
|
|
|
PenaltyID1 = RETRY_PENALTY_IDX[RtyPtID][RateID]; /* TODO by page */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
|
2013-05-08 21:45:39 +00:00
|
|
|
(" NscDown init is %d\n", pRaInfo->NscDown));
|
|
|
|
pRaInfo->NscDown += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID1][0];
|
|
|
|
pRaInfo->NscDown += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID1][1];
|
|
|
|
pRaInfo->NscDown += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID1][2];
|
|
|
|
pRaInfo->NscDown += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID1][3];
|
|
|
|
pRaInfo->NscDown += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID1][4];
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
|
|
|
|
(" NscDown is %d, total*penalty[5] is %d\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->NscDown, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5])));
|
|
|
|
if (pRaInfo->NscDown > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]))
|
|
|
|
pRaInfo->NscDown -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5];
|
|
|
|
else
|
|
|
|
pRaInfo->NscDown=0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* rate up */
|
2013-05-08 21:45:39 +00:00
|
|
|
PenaltyID2 = RETRY_PENALTY_UP_IDX[RateID];
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
|
2013-05-08 21:45:39 +00:00
|
|
|
(" NscUp init is %d\n", pRaInfo->NscUp));
|
|
|
|
pRaInfo->NscUp += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID2][0];
|
|
|
|
pRaInfo->NscUp += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID2][1];
|
|
|
|
pRaInfo->NscUp += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID2][2];
|
|
|
|
pRaInfo->NscUp += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID2][3];
|
|
|
|
pRaInfo->NscUp += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID2][4];
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
|
|
|
|
("NscUp is %d, total*up[5] is %d\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->NscUp, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5])));
|
|
|
|
if (pRaInfo->NscUp > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]))
|
|
|
|
pRaInfo->NscUp -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5];
|
|
|
|
else
|
|
|
|
pRaInfo->NscUp = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE|ODM_COMP_INIT, ODM_DBG_LOUD,
|
|
|
|
(" RssiStaRa= %d RtyPtID=%d PenaltyID1=0x%x PenaltyID2=0x%x RateID=%d NscDown=%d NscUp=%d SGI=%d\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->RssiStaRA,RtyPtID, PenaltyID1,PenaltyID2, RateID, pRaInfo->NscDown, pRaInfo->NscUp, pRaInfo->RateSGI));
|
|
|
|
if ((pRaInfo->NscDown < N_THRESHOLD_LOW[RateID]) ||(pRaInfo->DROP>DROPING_NECESSARY[RateID]))
|
|
|
|
odm_RateDown_8188E(pDM_Odm,pRaInfo);
|
|
|
|
else if (pRaInfo->NscUp > N_THRESHOLD_HIGH[RateID])
|
|
|
|
odm_RateUp_8188E(pDM_Odm,pRaInfo);
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pRaInfo->DecisionRate > pRaInfo->HighestRate)
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->DecisionRate = pRaInfo->HighestRate;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
if ((pRaInfo->DecisionRate)==(pRaInfo->PreRate))
|
2013-05-08 21:45:39 +00:00
|
|
|
DynamicTxRPTTimingCounter+=1;
|
|
|
|
else
|
|
|
|
DynamicTxRPTTimingCounter=0;
|
|
|
|
|
|
|
|
if (DynamicTxRPTTimingCounter>=4) {
|
|
|
|
odm_SetTxRPTTiming_8188E(pDM_Odm,pRaInfo, 1);
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("<=====Rate don't change 4 times, Extend RPT Timing\n"));
|
|
|
|
DynamicTxRPTTimingCounter=0;
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
pRaInfo->PreRate = pRaInfo->DecisionRate; /* YJ,add,120120 */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
odm_ResetRaCounter_8188E( pRaInfo);
|
|
|
|
}
|
2013-05-09 04:09:18 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<=====odm_RateDecision_8188E()\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
static int
|
2013-05-08 21:45:39 +00:00
|
|
|
odm_ARFBRefresh_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct * pDM_Odm,
|
|
|
|
struct odm_ra_info *pRaInfo
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
2013-07-10 18:25:07 +00:00
|
|
|
{ /* Wilson 2011/10/26 */
|
2013-05-08 21:45:39 +00:00
|
|
|
u4Byte MaskFromReg;
|
|
|
|
s1Byte i;
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
switch (pRaInfo->RateID){
|
2013-05-08 21:45:39 +00:00
|
|
|
case RATR_INX_WIRELESS_NGB:
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&0x0f8ff015;
|
|
|
|
break;
|
|
|
|
case RATR_INX_WIRELESS_NG:
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&0x0f8ff010;
|
|
|
|
break;
|
|
|
|
case RATR_INX_WIRELESS_NB:
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&0x0f8ff005;
|
|
|
|
break;
|
|
|
|
case RATR_INX_WIRELESS_N:
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&0x0f8ff000;
|
|
|
|
break;
|
|
|
|
case RATR_INX_WIRELESS_GB:
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&0x00000ff5;
|
|
|
|
break;
|
|
|
|
case RATR_INX_WIRELESS_G:
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&0x00000ff0;
|
|
|
|
break;
|
|
|
|
case RATR_INX_WIRELESS_B:
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&0x0000000d;
|
|
|
|
break;
|
2013-05-19 04:28:07 +00:00
|
|
|
case 12:
|
2013-05-08 21:45:39 +00:00
|
|
|
MaskFromReg=ODM_Read4Byte(pDM_Odm, REG_ARFR0);
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&MaskFromReg;
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
MaskFromReg=ODM_Read4Byte(pDM_Odm, REG_ARFR1);
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&MaskFromReg;
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
MaskFromReg=ODM_Read4Byte(pDM_Odm, REG_ARFR2);
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&MaskFromReg;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
MaskFromReg=ODM_Read4Byte(pDM_Odm, REG_ARFR3);
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask)&MaskFromReg;
|
|
|
|
break;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
default:
|
|
|
|
pRaInfo->RAUseRate=(pRaInfo->RateMask);
|
|
|
|
break;
|
|
|
|
}
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Highest rate */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pRaInfo->RAUseRate){
|
|
|
|
for (i=RATESIZE;i>=0;i--)
|
|
|
|
{
|
2013-05-09 04:04:25 +00:00
|
|
|
if ((pRaInfo->RAUseRate)&BIT(i)){
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->HighestRate=i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
pRaInfo->HighestRate=0;
|
|
|
|
}
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Lowest rate */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pRaInfo->RAUseRate){
|
|
|
|
for (i=0;i<RATESIZE;i++)
|
|
|
|
{
|
2013-05-09 04:04:25 +00:00
|
|
|
if ((pRaInfo->RAUseRate)&BIT(i))
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
pRaInfo->LowestRate=i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
pRaInfo->LowestRate=0;
|
|
|
|
}
|
|
|
|
if (pRaInfo->HighestRate >0x13)
|
|
|
|
pRaInfo->PTModeSS=3;
|
2013-05-09 04:04:25 +00:00
|
|
|
else if (pRaInfo->HighestRate >0x0b)
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->PTModeSS=2;
|
2013-05-09 04:04:25 +00:00
|
|
|
else if (pRaInfo->HighestRate >0x0b)
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->PTModeSS=1;
|
|
|
|
else
|
|
|
|
pRaInfo->PTModeSS=0;
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
|
2013-05-08 21:45:39 +00:00
|
|
|
("ODM_ARFBRefresh_8188E(): PTModeSS=%d\n", pRaInfo->PTModeSS));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pRaInfo->DecisionRate > pRaInfo->HighestRate)
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->DecisionRate = pRaInfo->HighestRate;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
|
|
|
|
("ODM_ARFBRefresh_8188E(): RateID=%d RateMask=%8.8x RAUseRate=%8.8x HighestRate=%d,DecisionRate=%d\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->RateID, pRaInfo->RateMask, pRaInfo->RAUseRate, pRaInfo->HighestRate,pRaInfo->DecisionRate));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
static void
|
2013-05-08 21:45:39 +00:00
|
|
|
odm_PTTryState_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_ra_info *pRaInfo
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
pRaInfo->PTTryState=0;
|
|
|
|
switch (pRaInfo->PTModeSS)
|
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
case 3:
|
|
|
|
if (pRaInfo->DecisionRate>=0x19)
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->PTTryState=1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (pRaInfo->DecisionRate>=0x11)
|
|
|
|
pRaInfo->PTTryState=1;
|
2013-05-19 04:28:07 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
case 1:
|
|
|
|
if (pRaInfo->DecisionRate>=0x0a)
|
|
|
|
pRaInfo->PTTryState=1;
|
2013-05-19 04:28:07 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
case 0:
|
|
|
|
if (pRaInfo->DecisionRate>=0x03)
|
|
|
|
pRaInfo->PTTryState=1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pRaInfo->PTTryState=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pRaInfo->RssiStaRA<48)
|
|
|
|
{
|
|
|
|
pRaInfo->PTStage=0;
|
|
|
|
}
|
|
|
|
else if (pRaInfo->PTTryState==1)
|
|
|
|
{
|
|
|
|
if ((pRaInfo->PTStopCount>=10)||(pRaInfo->PTPreRssi>pRaInfo->RssiStaRA+5)
|
|
|
|
||(pRaInfo->PTPreRssi<pRaInfo->RssiStaRA-5)||(pRaInfo->DecisionRate!=pRaInfo->PTPreRate))
|
|
|
|
{
|
|
|
|
if (pRaInfo->PTStage==0)
|
|
|
|
pRaInfo->PTStage=1;
|
2013-05-09 04:04:25 +00:00
|
|
|
else if (pRaInfo->PTStage==1)
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->PTStage=3;
|
|
|
|
else
|
|
|
|
pRaInfo->PTStage=5;
|
|
|
|
|
|
|
|
pRaInfo->PTPreRssi=pRaInfo->RssiStaRA;
|
|
|
|
pRaInfo->PTStopCount=0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
pRaInfo->RAstage=0;
|
|
|
|
pRaInfo->PTStopCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
pRaInfo->PTStage=0;
|
|
|
|
pRaInfo->RAstage=0;
|
|
|
|
}
|
|
|
|
pRaInfo->PTPreRate=pRaInfo->DecisionRate;
|
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
static void
|
2013-05-08 21:45:39 +00:00
|
|
|
odm_PTDecision_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_ra_info *pRaInfo
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
u1Byte j;
|
|
|
|
u1Byte temp_stage;
|
|
|
|
u4Byte numsc;
|
|
|
|
u4Byte num_total;
|
|
|
|
u1Byte stage_id;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
numsc = 0;
|
|
|
|
num_total= pRaInfo->TOTAL* PT_PENALTY[5];
|
2013-05-09 04:04:25 +00:00
|
|
|
for (j=0;j<=4;j++)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
numsc += pRaInfo->RTY[j] * PT_PENALTY[j];
|
2013-05-09 04:04:25 +00:00
|
|
|
if (numsc>num_total)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
j=j>>1;
|
|
|
|
temp_stage= (pRaInfo->PTStage +1)>>1;
|
|
|
|
if (temp_stage>j)
|
|
|
|
stage_id=temp_stage-j;
|
|
|
|
else
|
|
|
|
stage_id=0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->PTSmoothFactor=(pRaInfo->PTSmoothFactor>>1) + (pRaInfo->PTSmoothFactor>>2) + stage_id*16+2;
|
|
|
|
if (pRaInfo->PTSmoothFactor>192)
|
|
|
|
pRaInfo->PTSmoothFactor=192;
|
|
|
|
stage_id =pRaInfo->PTSmoothFactor>>6;
|
|
|
|
temp_stage=stage_id*2;
|
|
|
|
if (temp_stage!=0)
|
|
|
|
temp_stage-=1;
|
|
|
|
if (pRaInfo->DROP>3)
|
|
|
|
temp_stage=0;
|
|
|
|
pRaInfo->PTStage=temp_stage;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-05-19 04:37:45 +00:00
|
|
|
static void
|
2013-05-08 21:45:39 +00:00
|
|
|
odm_RATxRPTTimerSetting(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct * pDM_Odm,
|
2013-05-25 20:45:50 +00:00
|
|
|
u2Byte minRptTime
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,(" =====>odm_RATxRPTTimerSetting()\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pDM_Odm->CurrminRptTime != minRptTime){
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
|
2013-05-08 21:45:39 +00:00
|
|
|
(" CurrminRptTime =0x%04x minRptTime=0x%04x\n", pDM_Odm->CurrminRptTime, minRptTime));
|
|
|
|
rtw_rpt_timer_cfg_cmd(pDM_Odm->Adapter,minRptTime);
|
|
|
|
pDM_Odm->CurrminRptTime = minRptTime;
|
|
|
|
}
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,(" <=====odm_RATxRPTTimerSetting()\n"));
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-19 04:37:45 +00:00
|
|
|
void
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RASupport_Init(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct *pDM_Odm
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>ODM_RASupport_Init()\n"));
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* 2012/02/14 MH Be noticed, the init must be after IC type is recognized!!!!! */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pDM_Odm->SupportICType == ODM_RTL8188E)
|
2013-05-27 22:32:24 +00:00
|
|
|
pDM_Odm->RaSupport88E = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
int
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RAInfo_Init(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct *pDM_Odm,
|
2013-05-25 20:45:50 +00:00
|
|
|
u1Byte MacID
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_ra_info *pRaInfo = &pDM_Odm->RAInfo[MacID];
|
2013-07-10 18:25:07 +00:00
|
|
|
u1Byte WirelessMode=0xFF; /* invalid value */
|
|
|
|
u1Byte max_rate_idx = 0x13; /* MCS7 */
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pDM_Odm->pWirelessMode!=NULL){
|
2013-05-19 04:28:07 +00:00
|
|
|
WirelessMode=*(pDM_Odm->pWirelessMode);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (WirelessMode != 0xFF ){
|
|
|
|
if (WirelessMode & ODM_WM_N24G)
|
2013-05-08 21:45:39 +00:00
|
|
|
max_rate_idx = 0x13;
|
2013-05-09 04:04:25 +00:00
|
|
|
else if (WirelessMode & ODM_WM_G)
|
2013-05-08 21:45:39 +00:00
|
|
|
max_rate_idx = 0x0b;
|
2013-05-09 04:04:25 +00:00
|
|
|
else if (WirelessMode & ODM_WM_B)
|
2013-05-08 21:45:39 +00:00
|
|
|
max_rate_idx = 0x03;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
|
|
|
|
("ODM_RAInfo_Init(): WirelessMode:0x%08x ,max_raid_idx:0x%02x\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
WirelessMode,max_rate_idx));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->DecisionRate = max_rate_idx;
|
|
|
|
pRaInfo->PreRate = max_rate_idx;
|
|
|
|
pRaInfo->HighestRate=max_rate_idx;
|
|
|
|
pRaInfo->LowestRate=0;
|
|
|
|
pRaInfo->RateID=0;
|
|
|
|
pRaInfo->RateMask=0xffffffff;
|
|
|
|
pRaInfo->RssiStaRA=0;
|
|
|
|
pRaInfo->PreRssiStaRA=0;
|
|
|
|
pRaInfo->SGIEnable=0;
|
|
|
|
pRaInfo->RAUseRate=0xffffffff;
|
|
|
|
pRaInfo->NscDown=(N_THRESHOLD_HIGH[0x13]+N_THRESHOLD_LOW[0x13])/2;
|
|
|
|
pRaInfo->NscUp=(N_THRESHOLD_HIGH[0x13]+N_THRESHOLD_LOW[0x13])/2;
|
|
|
|
pRaInfo->RateSGI=0;
|
2013-07-10 18:25:07 +00:00
|
|
|
pRaInfo->Active=1; /* Active is not used at present. by page, 110819 */
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->RptTime = 0x927c;
|
|
|
|
pRaInfo->DROP=0;
|
|
|
|
pRaInfo->RTY[0]=0;
|
|
|
|
pRaInfo->RTY[1]=0;
|
|
|
|
pRaInfo->RTY[2]=0;
|
|
|
|
pRaInfo->RTY[3]=0;
|
|
|
|
pRaInfo->RTY[4]=0;
|
|
|
|
pRaInfo->TOTAL=0;
|
|
|
|
pRaInfo->RAWaitingCounter=0;
|
|
|
|
pRaInfo->RAPendingCounter=0;
|
2013-07-10 18:25:07 +00:00
|
|
|
pRaInfo->PTActive=1; /* Active when this STA is use */
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->PTTryState=0;
|
2013-07-10 18:25:07 +00:00
|
|
|
pRaInfo->PTStage=5; /* Need to fill into HW_PWR_STATUS */
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo->PTSmoothFactor=192;
|
|
|
|
pRaInfo->PTStopCount=0;
|
|
|
|
pRaInfo->PTPreRate=0;
|
|
|
|
pRaInfo->PTPreRssi=0;
|
|
|
|
pRaInfo->PTModeSS=0;
|
|
|
|
pRaInfo->RAstage=0;
|
2013-07-27 02:52:05 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
int
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RAInfo_Init_all(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct * pDM_Odm
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
u1Byte MacID = 0;
|
|
|
|
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>\n"));
|
|
|
|
pDM_Odm->CurrminRptTime = 0;
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
for (MacID=0; MacID<ODM_ASSOCIATE_ENTRY_NUM; MacID++)
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RAInfo_Init(pDM_Odm,MacID);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
u1Byte
|
|
|
|
ODM_RA_GetShortGI_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct *pDM_Odm,
|
2013-05-25 20:45:50 +00:00
|
|
|
u1Byte MacID
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
2013-05-09 04:04:25 +00:00
|
|
|
if ((NULL == pDM_Odm) || (MacID >= ASSOCIATE_ENTRY_NUM))
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
|
2013-05-08 21:45:39 +00:00
|
|
|
("MacID=%d SGI=%d\n", MacID, pDM_Odm->RAInfo[MacID].RateSGI));
|
|
|
|
return pDM_Odm->RAInfo[MacID].RateSGI;
|
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
u1Byte
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RA_GetDecisionRate_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct *pDM_Odm,
|
2013-05-25 20:45:50 +00:00
|
|
|
u1Byte MacID
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
u1Byte DecisionRate = 0;
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if ((NULL == pDM_Odm) || (MacID >= ASSOCIATE_ENTRY_NUM))
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
DecisionRate = (pDM_Odm->RAInfo[MacID].DecisionRate);
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
|
2013-05-08 21:45:39 +00:00
|
|
|
(" MacID=%d DecisionRate=0x%x\n", MacID, DecisionRate));
|
|
|
|
return DecisionRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
u1Byte
|
|
|
|
ODM_RA_GetHwPwrStatus_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct *pDM_Odm,
|
2013-05-25 20:45:50 +00:00
|
|
|
u1Byte MacID
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
u1Byte PTStage = 5;
|
2013-05-09 04:04:25 +00:00
|
|
|
if ((NULL == pDM_Odm) || (MacID >= ASSOCIATE_ENTRY_NUM))
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
PTStage = (pDM_Odm->RAInfo[MacID].PTStage);
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
|
2013-05-08 21:45:39 +00:00
|
|
|
("MacID=%d PTStage=0x%x\n", MacID, PTStage));
|
|
|
|
return PTStage;
|
|
|
|
}
|
|
|
|
|
2013-05-19 04:37:45 +00:00
|
|
|
void
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RA_UpdateRateInfo_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct *pDM_Odm,
|
2013-05-27 03:51:56 +00:00
|
|
|
u1Byte MacID,
|
|
|
|
u1Byte RateID,
|
|
|
|
u4Byte RateMask,
|
|
|
|
u1Byte SGIEnable
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_ra_info *pRaInfo = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
|
|
|
|
("MacID=%d RateID=0x%x RateMask=0x%x SGIEnable=%d\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
MacID, RateID, RateMask, SGIEnable));
|
2013-05-09 04:04:25 +00:00
|
|
|
if ((NULL == pDM_Odm) || (MacID >= ASSOCIATE_ENTRY_NUM))
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pRaInfo = &(pDM_Odm->RAInfo[MacID]);
|
|
|
|
pRaInfo->RateID = RateID;
|
|
|
|
pRaInfo->RateMask = RateMask;
|
|
|
|
pRaInfo->SGIEnable = SGIEnable;
|
|
|
|
odm_ARFBRefresh_8188E(pDM_Odm, pRaInfo);
|
|
|
|
}
|
|
|
|
|
2013-05-19 04:37:45 +00:00
|
|
|
void
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RA_SetRSSI_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct * pDM_Odm,
|
2013-05-25 20:45:50 +00:00
|
|
|
u1Byte MacID,
|
|
|
|
u1Byte Rssi
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_ra_info *pRaInfo = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
|
2013-05-08 21:45:39 +00:00
|
|
|
(" MacID=%d Rssi=%d\n", MacID, Rssi));
|
2013-05-09 04:04:25 +00:00
|
|
|
if ((NULL == pDM_Odm) || (MacID >= ASSOCIATE_ENTRY_NUM))
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
pRaInfo = &(pDM_Odm->RAInfo[MacID]);
|
|
|
|
pRaInfo->RssiStaRA = Rssi;
|
|
|
|
}
|
|
|
|
|
2013-05-19 04:37:45 +00:00
|
|
|
void
|
2013-05-08 21:45:39 +00:00
|
|
|
ODM_RA_Set_TxRPT_Time(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct * pDM_Odm,
|
2013-05-25 20:45:50 +00:00
|
|
|
u2Byte minRptTime
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
ODM_Write2Byte(pDM_Odm, REG_TX_RPT_TIME, minRptTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-19 04:37:45 +00:00
|
|
|
void
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RA_TxRPT2Handle_8188E(
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_dm_struct * pDM_Odm,
|
2013-05-25 20:45:50 +00:00
|
|
|
pu1Byte TxRPT_Buf,
|
|
|
|
u2Byte TxRPT_Len,
|
|
|
|
u4Byte MacIDValidEntry0,
|
|
|
|
u4Byte MacIDValidEntry1
|
2013-05-08 21:45:39 +00:00
|
|
|
)
|
|
|
|
{
|
2013-07-26 16:20:42 +00:00
|
|
|
struct odm_ra_info *pRAInfo = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
u1Byte MacId = 0;
|
|
|
|
pu1Byte pBuffer = NULL;
|
|
|
|
u4Byte valid = 0, ItemNum = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
u2Byte minRptTime = 0x927c;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>ODM_RA_TxRPT2Handle_8188E(): valid0=%d valid1=%d BufferLength=%d\n",
|
|
|
|
MacIDValidEntry0, MacIDValidEntry1, TxRPT_Len));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
ItemNum = TxRPT_Len >> 3;
|
|
|
|
pBuffer = TxRPT_Buf;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2013-05-09 04:04:25 +00:00
|
|
|
if (MacId >= ASSOCIATE_ENTRY_NUM)
|
2013-05-08 21:45:39 +00:00
|
|
|
valid = 0;
|
2013-05-09 04:04:25 +00:00
|
|
|
else if (MacId >= 32)
|
2013-05-08 21:45:39 +00:00
|
|
|
valid = (1<<(MacId-32)) & MacIDValidEntry1;
|
|
|
|
else
|
|
|
|
valid = (1<<MacId) & MacIDValidEntry0;
|
|
|
|
|
|
|
|
pRAInfo = &(pDM_Odm->RAInfo[MacId]);
|
2013-05-09 04:04:25 +00:00
|
|
|
if (valid)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
pRAInfo->RTY[0] = (u2Byte)GET_TX_REPORT_TYPE1_RERTY_0(pBuffer);
|
|
|
|
pRAInfo->RTY[1] = (u2Byte)GET_TX_REPORT_TYPE1_RERTY_1(pBuffer);
|
|
|
|
pRAInfo->RTY[2] = (u2Byte)GET_TX_REPORT_TYPE1_RERTY_2(pBuffer);
|
|
|
|
pRAInfo->RTY[3] = (u2Byte)GET_TX_REPORT_TYPE1_RERTY_3(pBuffer);
|
|
|
|
pRAInfo->RTY[4] = (u2Byte)GET_TX_REPORT_TYPE1_RERTY_4(pBuffer);
|
|
|
|
pRAInfo->DROP = (u2Byte)GET_TX_REPORT_TYPE1_DROP_0(pBuffer);
|
|
|
|
pRAInfo->TOTAL = pRAInfo->RTY[0] + \
|
|
|
|
pRAInfo->RTY[1] + \
|
|
|
|
pRAInfo->RTY[2] + \
|
|
|
|
pRAInfo->RTY[3] + \
|
|
|
|
pRAInfo->RTY[4] + \
|
|
|
|
pRAInfo->DROP;
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pRAInfo->TOTAL != 0)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
|
|
|
|
("macid=%d Total=%d R0=%d R1=%d R2=%d R3=%d R4=%d D0=%d valid0=%x valid1=%x\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
MacId,
|
|
|
|
pRAInfo->TOTAL,
|
|
|
|
pRAInfo->RTY[0],
|
|
|
|
pRAInfo->RTY[1],
|
|
|
|
pRAInfo->RTY[2],
|
|
|
|
pRAInfo->RTY[3],
|
|
|
|
pRAInfo->RTY[4],
|
|
|
|
pRAInfo->DROP,
|
|
|
|
MacIDValidEntry0 ,
|
|
|
|
MacIDValidEntry1));
|
|
|
|
if (pRAInfo->PTActive){
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pRAInfo->RAstage<5){
|
2013-05-08 21:45:39 +00:00
|
|
|
odm_RateDecision_8188E(pDM_Odm,pRAInfo);
|
|
|
|
}
|
2013-07-10 18:25:07 +00:00
|
|
|
else if (pRAInfo->RAstage==5){ /* Power training try state */
|
2013-05-08 21:45:39 +00:00
|
|
|
odm_PTTryState_8188E(pRAInfo);
|
|
|
|
}
|
2013-07-10 18:25:07 +00:00
|
|
|
else {/* RAstage==6 */
|
2013-05-08 21:45:39 +00:00
|
|
|
odm_PTDecision_8188E(pRAInfo);
|
|
|
|
}
|
|
|
|
|
2013-07-10 18:25:07 +00:00
|
|
|
/* Stage_RA counter */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pRAInfo->RAstage<=5)
|
|
|
|
pRAInfo->RAstage++;
|
|
|
|
else
|
|
|
|
pRAInfo->RAstage=0;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
odm_RateDecision_8188E(pDM_Odm,pRAInfo);
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
|
|
|
|
("macid=%d R0=%d R1=%d R2=%d R3=%d R4=%d drop=%d valid0=%x RateID=%d SGI=%d\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
MacId,
|
|
|
|
pRAInfo->RTY[0],
|
|
|
|
pRAInfo->RTY[1],
|
|
|
|
pRAInfo->RTY[2],
|
|
|
|
pRAInfo->RTY[3],
|
|
|
|
pRAInfo->RTY[4],
|
|
|
|
pRAInfo->DROP,
|
|
|
|
MacIDValidEntry0,
|
|
|
|
pRAInfo->DecisionRate,
|
|
|
|
pRAInfo->RateSGI));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, (" TOTAL=0!!!!\n"));
|
|
|
|
}
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (minRptTime > pRAInfo->RptTime)
|
2013-05-19 04:28:07 +00:00
|
|
|
minRptTime = pRAInfo->RptTime;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pBuffer += TX_RPT2_ITEM_SIZE;
|
|
|
|
MacId++;
|
2013-05-09 04:04:25 +00:00
|
|
|
}while (MacId < ItemNum);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
odm_RATxRPTTimerSetting(pDM_Odm,minRptTime);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("<===== ODM_RA_TxRPT2Handle_8188E()\n"));
|
|
|
|
}
|