From a311b57c3238ca3d193ed17a4538ebc43f29b31b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 8 Aug 2013 22:23:49 -0500 Subject: [PATCH] rtl8188eu: Fix remaining checkfile errors in hal/*.c Signed-off-by: Larry Finger --- hal/Hal8188ERateAdaptive.c | 965 +++++------ hal/HalHWImg8188E_RF.c | 2 +- hal/hal_intf.c | 2 +- hal/rtl8188e_rxdesc.c | 103 +- hal/rtl8188e_sreset.c | 75 +- hal/rtl8188e_xmit.c | 68 +- hal/rtl8188eu_led.c | 136 +- hal/rtl8188eu_recv.c | 77 +- hal/rtl8188eu_xmit.c | 429 ++--- hal/usb_halinit.c | 3367 ++++++++++++++++-------------------- hal/usb_ops_linux.c | 318 ++-- include/rtl8188e_hal.h | 2 + 12 files changed, 2406 insertions(+), 3138 deletions(-) diff --git a/hal/Hal8188ERateAdaptive.c b/hal/Hal8188ERateAdaptive.c index 606e186..ef81bb2 100644 --- a/hal/Hal8188ERateAdaptive.c +++ b/hal/Hal8188ERateAdaptive.c @@ -18,79 +18,81 @@ Major Change History: /* 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 */ + {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 */ +static u1Byte RETRY_PENALTY_UP[RETRYSIZE+1] = {49, 44, 16, 16, 0, 48}; /* 12% for rate up */ -static u1Byte PT_PENALTY[RETRYSIZE+1]={34,31,30,24,0,32}; +static u1Byte PT_PENALTY[RETRYSIZE+1] = {34, 31, 30, 24, 0, 32}; /* 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, /* SSTH */ + 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, /* SSTH */ - 0x0f,0x10,0x10,0x12,0x12,0x13,0x14,0x15, - 0x11,0x11,0x12,0x13,0x13,0x13,0x14,0x15}; +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}; +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}; -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 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 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]={ +static u4Byte INIT_RATE_FALLBACK_TABLE[16] = { 0x0f8ff015, /* 0: 40M BGN mode */ 0x0f8ff010, /* 1: 40M GN mode */ 0x0f8ff005, /* 2: BN mode/ 40M BGN mode */ @@ -109,70 +111,65 @@ static u4Byte INIT_RATE_FALLBACK_TABLE[16]={ 0, /* 15: */ }; -static u1Byte PendingForRateUpFail[5] = {2,10,24,40,60}; +static u1Byte PendingForRateUpFail[5] = {2, 10, 24, 40, 60}; static u2Byte DynamicTxRPTTiming[6] = { - 0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12 ,0x927c}; /* 200ms-1200ms */ + 0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12 , 0x927c}; /* 200ms-1200ms */ /* End Rate adaptive parameters */ static void odm_SetTxRPTTiming_8188E( - struct odm_dm_struct * pDM_Odm, + struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo, - u1Byte extend + u1Byte extend ) { u1Byte idx = 0; - for (idx=0; idx<5; idx++) + for (idx = 0; idx < 5; idx++) if (DynamicTxRPTTiming[idx] == pRaInfo->RptTime) break; - if (extend==0) /* back to default timing */ - idx=0; /* 200ms */ - else if (extend==1) {/* increase the timing */ - idx+=1; - if (idx>5) - idx=5; + if (extend == 0) { /* back to default timing */ + idx = 0; /* 200ms */ + } else if (extend == 1) {/* increase the timing */ + idx += 1; + if (idx > 5) + idx = 5; + } else if (extend == 2) {/* decrease the timing */ + if (idx != 0) + idx -= 1; } - else if (extend==2) {/* decrease the timing */ - if (idx!=0) - idx-=1; - } - pRaInfo->RptTime=DynamicTxRPTTiming[idx]; + pRaInfo->RptTime = DynamicTxRPTTiming[idx]; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("pRaInfo->RptTime=0x%x\n", pRaInfo->RptTime)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("pRaInfo->RptTime = 0x%x\n", pRaInfo->RptTime)); } -static int odm_RateDown_8188E( - struct odm_dm_struct *pDM_Odm, - struct odm_ra_info *pRaInfo - ) +static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) { u1Byte RateID, LowestRate, HighestRate; u1Byte i; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDown_8188E()\n")); - if (NULL == pRaInfo) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateDown_8188E(): pRaInfo is NULL\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDown_8188E()\n")); + if (NULL == pRaInfo) { + ODM_RT_TRACE(dm_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; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" RateID=%d LowestRate=%d HighestRate=%d RateSGI=%d\n", - RateID, LowestRate, HighestRate, pRaInfo->RateSGI)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" RateID =%d LowestRate =%d HighestRate =%d RateSGI =%d\n", + RateID, LowestRate, HighestRate, pRaInfo->RateSGI)); if (RateID > HighestRate) { - RateID=HighestRate; + RateID = HighestRate; } else if (pRaInfo->RateSGI) { - pRaInfo->RateSGI=0; + pRaInfo->RateSGI = 0; } else if (RateID > LowestRate) { if (RateID > 0) { - for (i=RateID-1; i>LowestRate;i--) { + for (i = RateID-1; i > LowestRate; i--) { if (pRaInfo->RAUseRate & BIT(i)) { - RateID=i; + RateID = i; goto RateDownFinish; } } @@ -181,105 +178,108 @@ static int odm_RateDown_8188E( RateID = LowestRate; } RateDownFinish: - if (pRaInfo->RAWaitingCounter==1){ - pRaInfo->RAWaitingCounter+=1; - pRaInfo->RAPendingCounter+=1; - } else if (pRaInfo->RAWaitingCounter==0){ + if (pRaInfo->RAWaitingCounter == 1) { + pRaInfo->RAWaitingCounter += 1; + pRaInfo->RAPendingCounter += 1; + } else if (pRaInfo->RAWaitingCounter == 0) { + ; } else { - pRaInfo->RAWaitingCounter=0; - pRaInfo->RAPendingCounter=0; + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; } - if (pRaInfo->RAPendingCounter>=4) - pRaInfo->RAPendingCounter=4; + if (pRaInfo->RAPendingCounter >= 4) + pRaInfo->RAPendingCounter = 4; - 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)); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<=====odm_RateDown_8188E()\n")); + pRaInfo->DecisionRate = RateID; + odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 2); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down, RPT Timing default\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down to RateID %d RateSGI %d\n", RateID, pRaInfo->RateSGI)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateDown_8188E()\n")); return 0; } static int odm_RateUp_8188E( - struct odm_dm_struct * pDM_Odm, + struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo ) { u1Byte RateID, HighestRate; u1Byte i; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateUp_8188E()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateUp_8188E()\n")); if (NULL == pRaInfo) { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E(): pRaInfo is NULL\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E(): pRaInfo is NULL\n")); return -1; } RateID = pRaInfo->PreRate; HighestRate = pRaInfo->HighestRate; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" RateID=%d HighestRate=%d\n", - RateID, HighestRate)); - if (pRaInfo->RAWaitingCounter==1){ - pRaInfo->RAWaitingCounter=0; - pRaInfo->RAPendingCounter=0; - } else if (pRaInfo->RAWaitingCounter>1){ - pRaInfo->PreRssiStaRA=pRaInfo->RssiStaRA; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" RateID =%d HighestRate =%d\n", + RateID, HighestRate)); + if (pRaInfo->RAWaitingCounter == 1) { + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; + } else if (pRaInfo->RAWaitingCounter > 1) { + 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")); + odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 0); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E():Decrease RPT Timing\n")); if (RateID < HighestRate) { - for (i=RateID+1; i<=HighestRate; i++) { + for (i = RateID+1; i <= HighestRate; i++) { if (pRaInfo->RAUseRate & BIT(i)) { - RateID=i; + RateID = i; goto RateUpfinish; } } } else if (RateID == HighestRate) { if (pRaInfo->SGIEnable && (pRaInfo->RateSGI != 1)) pRaInfo->RateSGI = 1; - else if ((pRaInfo->SGIEnable) !=1 ) + else if ((pRaInfo->SGIEnable) != 1) pRaInfo->RateSGI = 0; } else { RateID = HighestRate; } RateUpfinish: - if (pRaInfo->RAWaitingCounter==(4+PendingForRateUpFail[pRaInfo->RAPendingCounter])) - pRaInfo->RAWaitingCounter=0; + if (pRaInfo->RAWaitingCounter == (4+PendingForRateUpFail[pRaInfo->RAPendingCounter])) + 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)); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<=====odm_RateUp_8188E()\n")); + pRaInfo->DecisionRate = RateID; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate up to RateID %d\n", RateID)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateUp_8188E()\n")); return 0; } -static void odm_ResetRaCounter_8188E(struct odm_ra_info *pRaInfo){ +static void odm_ResetRaCounter_8188E(struct odm_ra_info *pRaInfo) +{ 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; + + 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; } -static void odm_RateDecision_8188E(struct odm_dm_struct * pDM_Odm, +static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo ) { u1Byte RateID = 0, RtyPtID = 0, PenaltyID1 = 0, PenaltyID2 = 0; /* u4Byte pool_retry; */ - static u1Byte DynamicTxRPTTimingCounter=0; + static u1Byte DynamicTxRPTTimingCounter; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDecision_8188E()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDecision_8188E()\n")); - if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) /* STA used and data packet exits */ - { - if ( (pRaInfo->RssiStaRA<(pRaInfo->PreRssiStaRA-3))|| (pRaInfo->RssiStaRA>(pRaInfo->PreRssiStaRA+3))){ - pRaInfo->RAWaitingCounter=0; - pRaInfo->RAPendingCounter=0; + if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) { /* STA used and data packet exits */ + if ((pRaInfo->RssiStaRA < (pRaInfo->PreRssiStaRA - 3)) || + (pRaInfo->RssiStaRA > (pRaInfo->PreRssiStaRA + 3))) { + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; } /* Start RA decision */ if (pRaInfo->PreRate > pRaInfo->HighestRate) @@ -287,235 +287,216 @@ static void odm_RateDecision_8188E(struct odm_dm_struct * pDM_Odm, else RateID = pRaInfo->PreRate; if (pRaInfo->RssiStaRA > RSSI_THRESHOLD[RateID]) - RtyPtID=0; + RtyPtID = 0; else - RtyPtID=1; + RtyPtID = 1; PenaltyID1 = RETRY_PENALTY_IDX[RtyPtID][RateID]; /* TODO by page */ - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" NscDown init is %d\n", pRaInfo->NscDown)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" 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]; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" NscDown is %d, total*penalty[5] is %d\n", - pRaInfo->NscDown, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]))); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" NscDown is %d, total*penalty[5] is %d\n", + 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; + pRaInfo->NscDown = 0; /* rate up */ PenaltyID2 = RETRY_PENALTY_UP_IDX[RateID]; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" NscUp init is %d\n", pRaInfo->NscUp)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" 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]; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("NscUp is %d, total*up[5] is %d\n", - pRaInfo->NscUp, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]))); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + ("NscUp is %d, total*up[5] is %d\n", + 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; - 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", - 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); + ODM_RT_TRACE(dm_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", + 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(dm_odm, pRaInfo); else if (pRaInfo->NscUp > N_THRESHOLD_HIGH[RateID]) - odm_RateUp_8188E(pDM_Odm,pRaInfo); + odm_RateUp_8188E(dm_odm, pRaInfo); if (pRaInfo->DecisionRate > pRaInfo->HighestRate) pRaInfo->DecisionRate = pRaInfo->HighestRate; - if ((pRaInfo->DecisionRate)==(pRaInfo->PreRate)) - DynamicTxRPTTimingCounter+=1; + if ((pRaInfo->DecisionRate) == (pRaInfo->PreRate)) + DynamicTxRPTTimingCounter += 1; else - DynamicTxRPTTimingCounter=0; + 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; + if (DynamicTxRPTTimingCounter >= 4) { + odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 1); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, + ODM_DBG_LOUD, ("<===== Rate don't change 4 times, Extend RPT Timing\n")); + DynamicTxRPTTimingCounter = 0; } - pRaInfo->PreRate = pRaInfo->DecisionRate; /* YJ,add,120120 */ + pRaInfo->PreRate = pRaInfo->DecisionRate; /* YJ, add, 120120 */ - odm_ResetRaCounter_8188E( pRaInfo); + odm_ResetRaCounter_8188E(pRaInfo); } - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<=====odm_RateDecision_8188E()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateDecision_8188E()\n")); } -static int -odm_ARFBRefresh_8188E( - struct odm_dm_struct * pDM_Odm, - struct odm_ra_info *pRaInfo - ) +static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) { /* Wilson 2011/10/26 */ u4Byte MaskFromReg; s1Byte i; - switch (pRaInfo->RateID){ - 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; - case 12: - 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; - - default: - pRaInfo->RAUseRate=(pRaInfo->RateMask); - break; + switch (pRaInfo->RateID) { + 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; + case 12: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR0); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + case 13: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR1); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + case 14: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR2); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + case 15: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR3); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + default: + pRaInfo->RAUseRate = (pRaInfo->RateMask); + break; } /* Highest rate */ - if (pRaInfo->RAUseRate){ - for (i=RATESIZE;i>=0;i--) - { - if ((pRaInfo->RAUseRate)&BIT(i)){ - pRaInfo->HighestRate=i; + if (pRaInfo->RAUseRate) { + for (i = RATESIZE; i >= 0; i--) { + if ((pRaInfo->RAUseRate)&BIT(i)) { + pRaInfo->HighestRate = i; break; } } - } - else{ - pRaInfo->HighestRate=0; + } else { + pRaInfo->HighestRate = 0; } /* Lowest rate */ - if (pRaInfo->RAUseRate){ - for (i=0;iRAUseRate)&BIT(i)) - { - pRaInfo->LowestRate=i; + if (pRaInfo->RAUseRate) { + for (i = 0; i < RATESIZE; i++) { + if ((pRaInfo->RAUseRate) & BIT(i)) { + pRaInfo->LowestRate = i; break; } } + } else { + pRaInfo->LowestRate = 0; } - else{ - pRaInfo->LowestRate=0; - } - if (pRaInfo->HighestRate >0x13) - pRaInfo->PTModeSS=3; - else if (pRaInfo->HighestRate >0x0b) - pRaInfo->PTModeSS=2; - else if (pRaInfo->HighestRate >0x0b) - pRaInfo->PTModeSS=1; + if (pRaInfo->HighestRate > 0x13) + pRaInfo->PTModeSS = 3; + else if (pRaInfo->HighestRate > 0x0b) + pRaInfo->PTModeSS = 2; + else if (pRaInfo->HighestRate > 0x0b) + pRaInfo->PTModeSS = 1; else - pRaInfo->PTModeSS=0; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("ODM_ARFBRefresh_8188E(): PTModeSS=%d\n", pRaInfo->PTModeSS)); + pRaInfo->PTModeSS = 0; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("ODM_ARFBRefresh_8188E(): PTModeSS =%d\n", pRaInfo->PTModeSS)); if (pRaInfo->DecisionRate > pRaInfo->HighestRate) pRaInfo->DecisionRate = pRaInfo->HighestRate; - 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", - pRaInfo->RateID, pRaInfo->RateMask, pRaInfo->RAUseRate, pRaInfo->HighestRate,pRaInfo->DecisionRate)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("ODM_ARFBRefresh_8188E(): RateID =%d RateMask =%8.8x RAUseRate =%8.8x HighestRate =%d, DecisionRate =%d\n", + pRaInfo->RateID, pRaInfo->RateMask, pRaInfo->RAUseRate, pRaInfo->HighestRate, pRaInfo->DecisionRate)); return 0; } -static void -odm_PTTryState_8188E( - struct odm_ra_info *pRaInfo - ) +static void odm_PTTryState_8188E(struct odm_ra_info *pRaInfo) { - pRaInfo->PTTryState=0; - switch (pRaInfo->PTModeSS) - { - case 3: - if (pRaInfo->DecisionRate>=0x19) - pRaInfo->PTTryState=1; - break; - case 2: - if (pRaInfo->DecisionRate>=0x11) - pRaInfo->PTTryState=1; - break; - case 1: - if (pRaInfo->DecisionRate>=0x0a) - pRaInfo->PTTryState=1; - break; - case 0: - if (pRaInfo->DecisionRate>=0x03) - pRaInfo->PTTryState=1; - break; - default: - pRaInfo->PTTryState=0; + pRaInfo->PTTryState = 0; + switch (pRaInfo->PTModeSS) { + case 3: + if (pRaInfo->DecisionRate >= 0x19) + pRaInfo->PTTryState = 1; + break; + case 2: + if (pRaInfo->DecisionRate >= 0x11) + pRaInfo->PTTryState = 1; + break; + case 1: + if (pRaInfo->DecisionRate >= 0x0a) + pRaInfo->PTTryState = 1; + break; + case 0: + if (pRaInfo->DecisionRate >= 0x03) + pRaInfo->PTTryState = 1; + break; + default: + pRaInfo->PTTryState = 0; + break; } - if (pRaInfo->RssiStaRA<48) - { - pRaInfo->PTStage=0; - } - else if (pRaInfo->PTTryState==1) - { - if ((pRaInfo->PTStopCount>=10)||(pRaInfo->PTPreRssi>pRaInfo->RssiStaRA+5) - ||(pRaInfo->PTPreRssiRssiStaRA-5)||(pRaInfo->DecisionRate!=pRaInfo->PTPreRate)) - { - if (pRaInfo->PTStage==0) - pRaInfo->PTStage=1; - else if (pRaInfo->PTStage==1) - pRaInfo->PTStage=3; + 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; + else if (pRaInfo->PTStage == 1) + pRaInfo->PTStage = 3; else - pRaInfo->PTStage=5; + pRaInfo->PTStage = 5; - pRaInfo->PTPreRssi=pRaInfo->RssiStaRA; - pRaInfo->PTStopCount=0; - - } - else{ - pRaInfo->RAstage=0; + pRaInfo->PTPreRssi = pRaInfo->RssiStaRA; + pRaInfo->PTStopCount = 0; + } else { + pRaInfo->RAstage = 0; pRaInfo->PTStopCount++; } + } else { + pRaInfo->PTStage = 0; + pRaInfo->RAstage = 0; } - else{ - pRaInfo->PTStage=0; - pRaInfo->RAstage=0; - } - pRaInfo->PTPreRate=pRaInfo->DecisionRate; + pRaInfo->PTPreRate = pRaInfo->DecisionRate; } -static void -odm_PTDecision_8188E( - struct odm_ra_info *pRaInfo - ) +static void odm_PTDecision_8188E(struct odm_ra_info *pRaInfo) { u1Byte j; u1Byte temp_stage; @@ -524,81 +505,70 @@ odm_PTDecision_8188E( u1Byte stage_id; numsc = 0; - num_total= pRaInfo->TOTAL* PT_PENALTY[5]; - for (j=0;j<=4;j++) - { + num_total = pRaInfo->TOTAL * PT_PENALTY[5]; + for (j = 0; j <= 4; j++) { numsc += pRaInfo->RTY[j] * PT_PENALTY[j]; - if (numsc>num_total) + if (numsc > num_total) break; } - j=j>>1; - temp_stage= (pRaInfo->PTStage +1)>>1; - if (temp_stage>j) - stage_id=temp_stage-j; + j = j >> 1; + temp_stage = (pRaInfo->PTStage + 1) >> 1; + if (temp_stage > j) + stage_id = temp_stage-j; else - stage_id=0; - - 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; + stage_id = 0; + 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; } static void odm_RATxRPTTimerSetting( - struct odm_dm_struct * pDM_Odm, - u2Byte minRptTime + struct odm_dm_struct *dm_odm, + u2Byte minRptTime ) { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,(" =====>odm_RATxRPTTimerSetting()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" =====>odm_RATxRPTTimerSetting()\n")); - - if (pDM_Odm->CurrminRptTime != minRptTime){ - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - (" CurrminRptTime =0x%04x minRptTime=0x%04x\n", pDM_Odm->CurrminRptTime, minRptTime)); - rtw_rpt_timer_cfg_cmd(pDM_Odm->Adapter,minRptTime); - pDM_Odm->CurrminRptTime = minRptTime; + if (dm_odm->CurrminRptTime != minRptTime) { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + (" CurrminRptTime = 0x%04x minRptTime = 0x%04x\n", dm_odm->CurrminRptTime, minRptTime)); + rtw_rpt_timer_cfg_cmd(dm_odm->Adapter, minRptTime); + dm_odm->CurrminRptTime = minRptTime; } - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,(" <=====odm_RATxRPTTimerSetting()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" <===== odm_RATxRPTTimerSetting()\n")); } void ODM_RASupport_Init( - struct odm_dm_struct *pDM_Odm + struct odm_dm_struct *dm_odm ) { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>ODM_RASupport_Init()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>ODM_RASupport_Init()\n")); /* 2012/02/14 MH Be noticed, the init must be after IC type is recognized!!!!! */ - if (pDM_Odm->SupportICType == ODM_RTL8188E) - pDM_Odm->RaSupport88E = true; - + if (dm_odm->SupportICType == ODM_RTL8188E) + dm_odm->RaSupport88E = true; } - - -int -ODM_RAInfo_Init( - struct odm_dm_struct *pDM_Odm, - u1Byte MacID - ) +int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u1Byte macid) { - struct odm_ra_info *pRaInfo = &pDM_Odm->RAInfo[MacID]; - u1Byte WirelessMode=0xFF; /* invalid value */ + struct odm_ra_info *pRaInfo = &dm_odm->RAInfo[macid]; + u1Byte WirelessMode = 0xFF; /* invalid value */ u1Byte max_rate_idx = 0x13; /* MCS7 */ - if (pDM_Odm->pWirelessMode!=NULL){ - WirelessMode=*(pDM_Odm->pWirelessMode); - } + if (dm_odm->pWirelessMode != NULL) + WirelessMode = *(dm_odm->pWirelessMode); - if (WirelessMode != 0xFF ){ + if (WirelessMode != 0xFF) { if (WirelessMode & ODM_WM_N24G) max_rate_idx = 0x13; else if (WirelessMode & ODM_WM_G) @@ -607,254 +577,200 @@ ODM_RAInfo_Init( max_rate_idx = 0x03; } - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("ODM_RAInfo_Init(): WirelessMode:0x%08x ,max_raid_idx:0x%02x\n", - WirelessMode,max_rate_idx)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("ODM_RAInfo_Init(): WirelessMode:0x%08x , max_raid_idx:0x%02x\n", + WirelessMode, max_rate_idx)); 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; - pRaInfo->Active=1; /* Active is not used at present. by page, 110819 */ + 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; + pRaInfo->Active = 1; /* Active is not used at present. by page, 110819 */ 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; - pRaInfo->PTActive=1; /* Active when this STA is use */ - pRaInfo->PTTryState=0; - pRaInfo->PTStage=5; /* Need to fill into HW_PWR_STATUS */ - pRaInfo->PTSmoothFactor=192; - pRaInfo->PTStopCount=0; - pRaInfo->PTPreRate=0; - pRaInfo->PTPreRssi=0; - pRaInfo->PTModeSS=0; - pRaInfo->RAstage=0; + 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; + pRaInfo->PTActive = 1; /* Active when this STA is use */ + pRaInfo->PTTryState = 0; + pRaInfo->PTStage = 5; /* Need to fill into HW_PWR_STATUS */ + pRaInfo->PTSmoothFactor = 192; + pRaInfo->PTStopCount = 0; + pRaInfo->PTPreRate = 0; + pRaInfo->PTPreRssi = 0; + pRaInfo->PTModeSS = 0; + pRaInfo->RAstage = 0; return 0; } -int -ODM_RAInfo_Init_all( - struct odm_dm_struct * pDM_Odm - ) +int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm) { - u1Byte MacID = 0; + u1Byte macid = 0; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>\n")); - pDM_Odm->CurrminRptTime = 0; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>\n")); + dm_odm->CurrminRptTime = 0; - for (MacID=0; MacID= ASSOCIATE_ENTRY_NUM)) + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return 0; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("MacID=%d SGI=%d\n", MacID, pDM_Odm->RAInfo[MacID].RateSGI)); - return pDM_Odm->RAInfo[MacID].RateSGI; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + ("macid =%d SGI =%d\n", macid, dm_odm->RAInfo[macid].RateSGI)); + return dm_odm->RAInfo[macid].RateSGI; } -u1Byte -ODM_RA_GetDecisionRate_8188E( - struct odm_dm_struct *pDM_Odm, - u1Byte MacID - ) +u1Byte ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u1Byte macid) { u1Byte DecisionRate = 0; - if ((NULL == pDM_Odm) || (MacID >= ASSOCIATE_ENTRY_NUM)) + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return 0; - DecisionRate = (pDM_Odm->RAInfo[MacID].DecisionRate); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" MacID=%d DecisionRate=0x%x\n", MacID, DecisionRate)); + DecisionRate = (dm_odm->RAInfo[macid].DecisionRate); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" macid =%d DecisionRate = 0x%x\n", macid, DecisionRate)); return DecisionRate; } -u1Byte -ODM_RA_GetHwPwrStatus_8188E( - struct odm_dm_struct *pDM_Odm, - u1Byte MacID - ) +u1Byte ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u1Byte macid) { u1Byte PTStage = 5; - if ((NULL == pDM_Odm) || (MacID >= ASSOCIATE_ENTRY_NUM)) + + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return 0; - PTStage = (pDM_Odm->RAInfo[MacID].PTStage); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("MacID=%d PTStage=0x%x\n", MacID, PTStage)); + PTStage = (dm_odm->RAInfo[macid].PTStage); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + ("macid =%d PTStage = 0x%x\n", macid, PTStage)); return PTStage; } -void -ODM_RA_UpdateRateInfo_8188E( - struct odm_dm_struct *pDM_Odm, - u1Byte MacID, - u1Byte RateID, - u4Byte RateMask, - u1Byte SGIEnable - ) +void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u1Byte macid, u1Byte RateID, u4Byte RateMask, u1Byte SGIEnable) { struct odm_ra_info *pRaInfo = NULL; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("MacID=%d RateID=0x%x RateMask=0x%x SGIEnable=%d\n", - MacID, RateID, RateMask, SGIEnable)); - if ((NULL == pDM_Odm) || (MacID >= ASSOCIATE_ENTRY_NUM)) + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("macid =%d RateID = 0x%x RateMask = 0x%x SGIEnable =%d\n", + macid, RateID, RateMask, SGIEnable)); + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return; - pRaInfo = &(pDM_Odm->RAInfo[MacID]); + pRaInfo = &(dm_odm->RAInfo[macid]); pRaInfo->RateID = RateID; pRaInfo->RateMask = RateMask; pRaInfo->SGIEnable = SGIEnable; - odm_ARFBRefresh_8188E(pDM_Odm, pRaInfo); + odm_ARFBRefresh_8188E(dm_odm, pRaInfo); } -void -ODM_RA_SetRSSI_8188E( - struct odm_dm_struct * pDM_Odm, - u1Byte MacID, - u1Byte Rssi - ) +void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u1Byte macid, u1Byte Rssi) { struct odm_ra_info *pRaInfo = NULL; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" MacID=%d Rssi=%d\n", MacID, Rssi)); - if ((NULL == pDM_Odm) || (MacID >= ASSOCIATE_ENTRY_NUM)) + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" macid =%d Rssi =%d\n", macid, Rssi)); + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return; - pRaInfo = &(pDM_Odm->RAInfo[MacID]); + pRaInfo = &(dm_odm->RAInfo[macid]); pRaInfo->RssiStaRA = Rssi; } -void -ODM_RA_Set_TxRPT_Time( - struct odm_dm_struct * pDM_Odm, - u2Byte minRptTime - ) +void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u2Byte minRptTime) { - ODM_Write2Byte(pDM_Odm, REG_TX_RPT_TIME, minRptTime); + ODM_Write2Byte(dm_odm, REG_TX_RPT_TIME, minRptTime); } - -void -ODM_RA_TxRPT2Handle_8188E( - struct odm_dm_struct * pDM_Odm, - pu1Byte TxRPT_Buf, - u2Byte TxRPT_Len, - u4Byte MacIDValidEntry0, - u4Byte MacIDValidEntry1 - ) +void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, pu1Byte TxRPT_Buf, u2Byte TxRPT_Len, u4Byte macid_entry0, u4Byte macid_entry1) { struct odm_ra_info *pRAInfo = NULL; - u1Byte MacId = 0; - pu1Byte pBuffer = NULL; - u4Byte valid = 0, ItemNum = 0; - u2Byte minRptTime = 0x927c; + u1Byte MacId = 0; + pu1Byte pBuffer = NULL; + u4Byte valid = 0, ItemNum = 0; + u2Byte minRptTime = 0x927c; - 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)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("=====>ODM_RA_TxRPT2Handle_8188E(): valid0 =%d valid1 =%d BufferLength =%d\n", + macid_entry0, macid_entry1, TxRPT_Len)); ItemNum = TxRPT_Len >> 3; pBuffer = TxRPT_Buf; - do - { + do { if (MacId >= ASSOCIATE_ENTRY_NUM) valid = 0; else if (MacId >= 32) - valid = (1<<(MacId-32)) & MacIDValidEntry1; + valid = (1 << (MacId - 32)) & macid_entry1; else - valid = (1<RAInfo[MacId]); - if (valid) - { + valid = (1 << MacId) & macid_entry0; + pRAInfo = &(dm_odm->RAInfo[MacId]); + if (valid) { 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; - if (pRAInfo->TOTAL != 0) - { - 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", - 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){ - if (pRAInfo->RAstage<5){ - odm_RateDecision_8188E(pDM_Odm,pRAInfo); - } - else if (pRAInfo->RAstage==5){ /* Power training try state */ + pRAInfo->TOTAL = pRAInfo->RTY[0] + pRAInfo->RTY[1] + + pRAInfo->RTY[2] + pRAInfo->RTY[3] + + pRAInfo->RTY[4] + pRAInfo->DROP; + if (pRAInfo->TOTAL != 0) { + ODM_RT_TRACE(dm_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", + MacId, pRAInfo->TOTAL, + pRAInfo->RTY[0], pRAInfo->RTY[1], + pRAInfo->RTY[2], pRAInfo->RTY[3], + pRAInfo->RTY[4], pRAInfo->DROP, + macid_entry0 , macid_entry1)); + if (pRAInfo->PTActive) { + if (pRAInfo->RAstage < 5) + odm_RateDecision_8188E(dm_odm, pRAInfo); + else if (pRAInfo->RAstage == 5) /* Power training try state */ odm_PTTryState_8188E(pRAInfo); - } - else {/* RAstage==6 */ + else /* RAstage == 6 */ odm_PTDecision_8188E(pRAInfo); - } /* Stage_RA counter */ - if (pRAInfo->RAstage<=5) + if (pRAInfo->RAstage <= 5) pRAInfo->RAstage++; else - pRAInfo->RAstage=0; + pRAInfo->RAstage = 0; + } else { + odm_RateDecision_8188E(dm_odm, pRAInfo); } - else{ - odm_RateDecision_8188E(pDM_Odm,pRAInfo); - } - 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", - MacId, - pRAInfo->RTY[0], - pRAInfo->RTY[1], - pRAInfo->RTY[2], - pRAInfo->RTY[3], - pRAInfo->RTY[4], - pRAInfo->DROP, - MacIDValidEntry0, - pRAInfo->DecisionRate, - pRAInfo->RateSGI)); + ODM_RT_TRACE(dm_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", + MacId, + pRAInfo->RTY[0], + pRAInfo->RTY[1], + pRAInfo->RTY[2], + pRAInfo->RTY[3], + pRAInfo->RTY[4], + pRAInfo->DROP, + macid_entry0, + pRAInfo->DecisionRate, + pRAInfo->RateSGI)); + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, (" TOTAL = 0!!!!\n")); } - else - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, (" TOTAL=0!!!!\n")); } if (minRptTime > pRAInfo->RptTime) @@ -862,10 +778,9 @@ ODM_RA_TxRPT2Handle_8188E( pBuffer += TX_RPT2_ITEM_SIZE; MacId++; - }while (MacId < ItemNum); + } while (MacId < ItemNum); - odm_RATxRPTTimerSetting(pDM_Odm,minRptTime); + odm_RATxRPTTimerSetting(dm_odm, minRptTime); - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("<===== ODM_RA_TxRPT2Handle_8188E()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("<===== ODM_RA_TxRPT2Handle_8188E()\n")); } diff --git a/hal/HalHWImg8188E_RF.c b/hal/HalHWImg8188E_RF.c index d783694..e7fe440 100644 --- a/hal/HalHWImg8188E_RF.c +++ b/hal/HalHWImg8188E_RF.c @@ -184,7 +184,7 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) if (biol) { pxmit_frame = rtw_IOL_accquire_xmit_frame(Adapter); - if (pxmit_frame== NULL) { + if (pxmit_frame == NULL) { pr_info("rtw_IOL_accquire_xmit_frame failed\n"); return HAL_STATUS_FAILURE; } diff --git a/hal/hal_intf.c b/hal/hal_intf.c index 52334fd..5b22878 100644 --- a/hal/hal_intf.c +++ b/hal/hal_intf.c @@ -212,7 +212,7 @@ u32 rtw_hal_inirp_deinit(struct adapter *adapt) } u8 rtw_hal_intf_ps_func(struct adapter *adapt, - enum hal_intf_ps_func efunc_id, u8 *val) + enum hal_intf_ps_func efunc_id, u8 *val) { if (adapt->HalFunc.interface_ps_func) return adapt->HalFunc.interface_ps_func(adapt, efunc_id, diff --git a/hal/rtl8188e_rxdesc.c b/hal/rtl8188e_rxdesc.c index acac955..1df0f33 100644 --- a/hal/rtl8188e_rxdesc.c +++ b/hal/rtl8188e_rxdesc.c @@ -27,7 +27,6 @@ static s32 translate2dbm(u8 signal_strength_idx) { s32 signal_power; /* in dBm. */ - /* Translate to dBm (x=0.5y-95). */ signal_power = (s32)((signal_strength_idx + 1) >> 1); signal_power -= 95; @@ -35,37 +34,31 @@ static s32 translate2dbm(u8 signal_strength_idx) return signal_power; } - -static void process_rssi(struct adapter *padapter,union recv_frame *prframe) +static void process_rssi(struct adapter *padapter, union recv_frame *prframe) { u32 last_rssi, tmp_val; struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; - struct signal_stat * signal_stat = &padapter->recvpriv.signal_strength_data; + struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data; - { - - if (signal_stat->update_req) { - signal_stat->total_num = 0; - signal_stat->total_val = 0; - signal_stat->update_req = 0; - } - - signal_stat->total_num++; - signal_stat->total_val += pattrib->phy_info.SignalStrength; - signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; + if (signal_stat->update_req) { + signal_stat->total_num = 0; + signal_stat->total_val = 0; + signal_stat->update_req = 0; } -}/* Process_UI_RSSI_8192C */ + signal_stat->total_num++; + signal_stat->total_val += pattrib->phy_info.SignalStrength; + signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; +} /* Process_UI_RSSI_8192C */ -static void process_link_qual(struct adapter *padapter,union recv_frame *prframe) +static void process_link_qual(struct adapter *padapter, union recv_frame *prframe) { - u32 last_evm=0, tmpVal; + u32 last_evm = 0, tmpVal; struct rx_pkt_attrib *pattrib; - struct signal_stat * signal_stat; + struct signal_stat *signal_stat; - if (prframe == NULL || padapter==NULL){ + if (prframe == NULL || padapter == NULL) return; - } pattrib = &prframe->u.hdr.attrib; signal_stat = &padapter->recvpriv.signal_qual_data; @@ -85,23 +78,13 @@ void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe) { union recv_frame *precvframe = (union recv_frame *)prframe; - /* */ /* Check RSSI */ - /* */ process_rssi(padapter, precvframe); - /* */ - /* Check PWDB. */ - /* */ - /* Check EVM */ process_link_qual(padapter, precvframe); - } - -void update_recvframe_attrib_88e( - union recv_frame *precvframe, - struct recv_stat *prxstat) +void update_recvframe_attrib_88e(union recv_frame *precvframe, struct recv_stat *prxstat) { struct rx_pkt_attrib *pattrib; struct recv_stat report; @@ -127,7 +110,7 @@ void update_recvframe_attrib_88e( pattrib->physt = (u8)((le32_to_cpu(report.rxdw0) >> 26) & 0x1);/* u8)prxreport->physt; */ - pattrib->bdecrypted = (le32_to_cpu(report.rxdw0) & BIT(27))? 0:1;/* u8)(prxreport->swdec ? 0 : 1); */ + pattrib->bdecrypted = (le32_to_cpu(report.rxdw0) & BIT(27)) ? 0 : 1;/* u8)(prxreport->swdec ? 0 : 1); */ pattrib->encrypt = (u8)((le32_to_cpu(report.rxdw0) >> 20) & 0x7);/* u8)prxreport->security; */ pattrib->qos = (u8)((le32_to_cpu(report.rxdw0) >> 23) & 0x1);/* u8)prxreport->qos; */ @@ -145,12 +128,11 @@ void update_recvframe_attrib_88e( pattrib->icv_err = (u8)((le32_to_cpu(report.rxdw0) >> 15) & 0x1);/* u8)prxreport->icverr; */ pattrib->shift_sz = (u8)((le32_to_cpu(report.rxdw0) >> 24) & 0x3); - } else if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX */ pattrib->pkt_len = TX_RPT1_PKT_LEN; pattrib->drvinfo_sz = 0; } else if (pattrib->pkt_rpt_type == TX_REPORT2) { /* TX RPT */ - pattrib->pkt_len =(u16)(le32_to_cpu(report.rxdw0) & 0x3FF);/* Rx length[9:0] */ + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x3FF);/* Rx length[9:0] */ pattrib->drvinfo_sz = 0; /* */ @@ -160,9 +142,8 @@ void update_recvframe_attrib_88e( pattrib->MacIDValidEntry[1] = le32_to_cpu(report.rxdw5); } else if (pattrib->pkt_rpt_type == HIS_REPORT) { /* USB HISR RPT */ - pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) &0x00003fff);/* u16)prxreport->pktlen; */ + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */ } - } /* @@ -170,21 +151,19 @@ void update_recvframe_attrib_88e( * Before calling this function, * precvframe->u.hdr.rx_data should be ready! */ -void update_recvframe_phyinfo_88e( - union recv_frame *precvframe, - struct phy_stat *pphy_status) +void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat *pphy_status) { struct adapter *padapter = precvframe->u.hdr.adapter; - struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); struct odm_phy_status_info *pPHYInfo = (struct odm_phy_status_info *)(&pattrib->phy_info); - u8 *wlanhdr; + u8 *wlanhdr; struct odm_per_pkt_info pkt_info; u8 *sa; struct sta_priv *pstapriv; struct sta_info *psta; - pkt_info.bPacketMatchBSSID =false; + pkt_info.bPacketMatchBSSID = false; pkt_info.bPacketToSelf = false; pkt_info.bPacketBeacon = false; @@ -192,19 +171,21 @@ void update_recvframe_phyinfo_88e( pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) && !pattrib->icv_err && !pattrib->crc_err && - _rtw_memcmp(get_hdr_bssid(wlanhdr), get_bssid(&padapter->mlmepriv), ETH_ALEN)); + _rtw_memcmp(get_hdr_bssid(wlanhdr), + get_bssid(&padapter->mlmepriv), ETH_ALEN)); - pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID && (_rtw_memcmp(get_da(wlanhdr), myid(&padapter->eeprompriv), ETH_ALEN)); + pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID && + (_rtw_memcmp(get_da(wlanhdr), + myid(&padapter->eeprompriv), ETH_ALEN)); - pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID && (GetFrameSubType(wlanhdr) == WIFI_BEACON); + pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID && + (GetFrameSubType(wlanhdr) == WIFI_BEACON); - if (pkt_info.bPacketBeacon){ - if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE) == true){ + if (pkt_info.bPacketBeacon) { + if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE)) sa = padapter->mlmepriv.cur_network.network.MacAddress; - } /* to do Ad-hoc */ - } - else{ + } else { sa = get_sa(wlanhdr); } @@ -215,27 +196,19 @@ void update_recvframe_phyinfo_88e( pkt_info.StationID = psta->mac_id; pkt_info.Rate = pattrib->mcs_rate; - ODM_PhyStatusQuery(&pHalData->odmpriv,pPHYInfo,(u8 *)pphy_status,&(pkt_info)); + ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info)); precvframe->u.hdr.psta = NULL; if (pkt_info.bPacketMatchBSSID && - (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true)) - { - if (psta) - { + (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) { + if (psta) { precvframe->u.hdr.psta = psta; rtl8188e_process_phy_info(padapter, precvframe); - } - } - else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) - { - if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true) - { + } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { + if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { if (psta) - { precvframe->u.hdr.psta = psta; - } } rtl8188e_process_phy_info(padapter, precvframe); } diff --git a/hal/rtl8188e_sreset.c b/hal/rtl8188e_sreset.c index 85b9107..2868269 100644 --- a/hal/rtl8188e_sreset.c +++ b/hal/rtl8188e_sreset.c @@ -22,45 +22,38 @@ #include #include -extern void rtw_cancel_all_timer(struct adapter *padapter); static void _restore_security_setting(struct adapter *padapter) { u8 EntryId = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv * pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta; - struct security_priv* psecuritypriv=&(padapter->securitypriv); + struct security_priv *psecuritypriv = &(padapter->securitypriv); struct mlme_ext_info *pmlmeinfo = &padapter->mlmeextpriv.mlmext_info; - (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) - ? rtw_write8(padapter, REG_SECCFG, 0xcc) - : rtw_write8(padapter, REG_SECCFG, 0xcf); + (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? + rtw_write8(padapter, REG_SECCFG, 0xcc) : + rtw_write8(padapter, REG_SECCFG, 0xcf); - if ( ( padapter->securitypriv.dot11PrivacyAlgrthm == _WEP40_ ) || - ( padapter->securitypriv.dot11PrivacyAlgrthm == _WEP104_ )) - { - - for (EntryId=0; EntryId<4; EntryId++) - { + if ((padapter->securitypriv.dot11PrivacyAlgrthm == _WEP40_) || + (padapter->securitypriv.dot11PrivacyAlgrthm == _WEP104_)) { + for (EntryId = 0; EntryId < 4; EntryId++) { if (EntryId == psecuritypriv->dot11PrivacyKeyIndex) - rtw_set_key(padapter,&padapter->securitypriv, EntryId, 1); + rtw_set_key(padapter, &padapter->securitypriv, EntryId, 1); else - rtw_set_key(padapter,&padapter->securitypriv, EntryId, 0); + rtw_set_key(padapter, &padapter->securitypriv, EntryId, 0); } - } - else if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || - (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) - { + } else if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || + (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); if (psta) { /* pairwise key */ rtw_setstakey_cmd(padapter, (unsigned char *)psta, true); /* group key */ - rtw_set_key(padapter,&padapter->securitypriv,padapter->securitypriv.dot118021XGrpKeyid, 0); + rtw_set_key(padapter, &padapter->securitypriv, padapter->securitypriv.dot118021XGrpKeyid, 0); } } - } static void _restore_network_status(struct adapter *padapter) @@ -68,7 +61,7 @@ static void _restore_network_status(struct adapter *padapter) struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex*)(&(pmlmeinfo->network)); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); unsigned short caps; u8 join_type; @@ -78,7 +71,7 @@ static void _restore_network_status(struct adapter *padapter) /* set MSR to nolink */ Set_MSR(padapter, _HW_STATE_NOLINK_); /* reject all data frame */ - rtw_write16(padapter, REG_RXFLTMAP2,0x00); + rtw_write16(padapter, REG_RXFLTMAP2, 0x00); /* reset TSF */ rtw_write8(padapter, REG_DUAL_TSF_RST, (BIT(0)|BIT(1))); @@ -114,7 +107,7 @@ static void _restore_network_status(struct adapter *padapter) mlmeext_joinbss_event_callback(padapter, 1); /* restore Sequence No. */ - rtw_write8(padapter,0x4dc,padapter->xmitpriv.nqos_ssn); + rtw_write8(padapter, 0x4dc, padapter->xmitpriv.nqos_ssn); } void rtl8188e_silentreset_for_specific_platform(struct adapter *padapter) @@ -131,24 +124,23 @@ void rtl8188e_sreset_xmit_status_check(struct adapter *padapter) unsigned int diff_time; u32 txdma_status; - if ( (txdma_status=rtw_read32(padapter, REG_TXDMA_STATUS)) !=0x00){ + txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS); + if (txdma_status != 0x00) { DBG_88E("%s REG_TXDMA_STATUS:0x%08x\n", __func__, txdma_status); - rtw_write32(padapter,REG_TXDMA_STATUS,txdma_status); + rtw_write32(padapter, REG_TXDMA_STATUS, txdma_status); rtl8188e_silentreset_for_specific_platform(padapter); } /* total xmit irp = 4 */ current_time = rtw_get_current_time(); - if (0==pxmitpriv->free_xmitbuf_cnt) - { + if (0 == pxmitpriv->free_xmitbuf_cnt) { diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_time); - if (diff_time > 2000){ - if (psrtpriv->last_tx_complete_time==0){ + if (diff_time > 2000) { + if (psrtpriv->last_tx_complete_time == 0) { psrtpriv->last_tx_complete_time = current_time; - } - else{ + } else { diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_complete_time); - if (diff_time > 4000){ + if (diff_time > 4000) { DBG_88E("%s tx hang\n", __func__); rtl8188e_silentreset_for_specific_platform(padapter); } @@ -160,18 +152,17 @@ void rtl8188e_sreset_xmit_status_check(struct adapter *padapter) void rtl8188e_sreset_linked_status_check(struct adapter *padapter) { u32 rx_dma_status = 0; - u8 fw_status=0; - rx_dma_status = rtw_read32(padapter,REG_RXDMA_STATUS); - if (rx_dma_status!= 0x00){ - DBG_88E("%s REG_RXDMA_STATUS:0x%08x\n",__func__,rx_dma_status); - rtw_write32(padapter,REG_RXDMA_STATUS,rx_dma_status); + u8 fw_status = 0; + rx_dma_status = rtw_read32(padapter, REG_RXDMA_STATUS); + if (rx_dma_status != 0x00) { + DBG_88E("%s REG_RXDMA_STATUS:0x%08x\n", __func__, rx_dma_status); + rtw_write32(padapter, REG_RXDMA_STATUS, rx_dma_status); } - fw_status = rtw_read8(padapter,REG_FMETHR); - if (fw_status != 0x00) - { + fw_status = rtw_read8(padapter, REG_FMETHR); + if (fw_status != 0x00) { if (fw_status == 1) - DBG_88E("%s REG_FW_STATUS (0x%02x), Read_Efuse_Fail !! \n",__func__,fw_status); + DBG_88E("%s REG_FW_STATUS (0x%02x), Read_Efuse_Fail !!\n", __func__, fw_status); else if (fw_status == 2) - DBG_88E("%s REG_FW_STATUS (0x%02x), Condition_No_Match !! \n",__func__,fw_status); + DBG_88E("%s REG_FW_STATUS (0x%02x), Condition_No_Match !!\n", __func__, fw_status); } } diff --git a/hal/rtl8188e_xmit.c b/hal/rtl8188e_xmit.c index 1420469..7ecbcf7 100644 --- a/hal/rtl8188e_xmit.c +++ b/hal/rtl8188e_xmit.c @@ -33,14 +33,15 @@ void dump_txrpt_ccx_88e(void *buf) "retry_cnt:%u, lifetime_over:%u, retry_over:%u\n" "ccx_qtime:%u\n" "final_data_rate:0x%02x\n" - "qsel:%u, sw:0x%03x\n" - , __func__ - , txrpt_ccx->tag1, txrpt_ccx->pkt_num, txrpt_ccx->txdma_underflow, txrpt_ccx->int_bt, txrpt_ccx->int_tri, txrpt_ccx->int_ccx - , txrpt_ccx->mac_id, txrpt_ccx->pkt_ok, txrpt_ccx->bmc - , txrpt_ccx->retry_cnt, txrpt_ccx->lifetime_over, txrpt_ccx->retry_over - , txrpt_ccx_qtime_88e(txrpt_ccx) - , txrpt_ccx->final_data_rate - , txrpt_ccx->qsel, txrpt_ccx_sw_88e(txrpt_ccx) + "qsel:%u, sw:0x%03x\n", + __func__, txrpt_ccx->tag1, txrpt_ccx->pkt_num, + txrpt_ccx->txdma_underflow, txrpt_ccx->int_bt, + txrpt_ccx->int_tri, txrpt_ccx->int_ccx, + txrpt_ccx->mac_id, txrpt_ccx->pkt_ok, txrpt_ccx->bmc, + txrpt_ccx->retry_cnt, txrpt_ccx->lifetime_over, + txrpt_ccx->retry_over, txrpt_ccx_qtime_88e(txrpt_ccx), + txrpt_ccx->final_data_rate, txrpt_ccx->qsel, + txrpt_ccx_sw_88e(txrpt_ccx) ); } @@ -50,44 +51,41 @@ void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf) if (txrpt_ccx->int_ccx) { if (txrpt_ccx->pkt_ok) - rtw_ack_tx_done(&adapter->xmitpriv, RTW_SCTX_DONE_SUCCESS); + rtw_ack_tx_done(&adapter->xmitpriv, + RTW_SCTX_DONE_SUCCESS); else - rtw_ack_tx_done(&adapter->xmitpriv, RTW_SCTX_DONE_CCX_PKT_FAIL); + rtw_ack_tx_done(&adapter->xmitpriv, + RTW_SCTX_DONE_CCX_PKT_FAIL); } } -void _dbg_dump_tx_info(struct adapter *padapter,int frame_tag,struct tx_desc *ptxdesc) +void _dbg_dump_tx_info(struct adapter *padapter, int frame_tag, + struct tx_desc *ptxdesc) { - u8 bDumpTxPkt; - u8 bDumpTxDesc = false; - rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(bDumpTxPkt)); + u8 dmp_txpkt; + bool dump_txdesc = false; + rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(dmp_txpkt)); - if (bDumpTxPkt ==1){/* dump txdesc for data frame */ + if (dmp_txpkt == 1) {/* dump txdesc for data frame */ DBG_88E("dump tx_desc for data frame\n"); - if ((frame_tag&0x0f) == DATA_FRAMETAG){ - bDumpTxDesc = true; - } - } - else if (bDumpTxPkt ==2){/* dump txdesc for mgnt frame */ + if ((frame_tag & 0x0f) == DATA_FRAMETAG) + dump_txdesc = true; + } else if (dmp_txpkt == 2) {/* dump txdesc for mgnt frame */ DBG_88E("dump tx_desc for mgnt frame\n"); - if ((frame_tag&0x0f) == MGNT_FRAMETAG){ - bDumpTxDesc = true; - } - } - else if (bDumpTxPkt ==3){/* dump early info */ + if ((frame_tag & 0x0f) == MGNT_FRAMETAG) + dump_txdesc = true; } - if (bDumpTxDesc){ + if (dump_txdesc) { DBG_88E("=====================================\n"); - DBG_88E("txdw0(0x%08x)\n",ptxdesc->txdw0); - DBG_88E("txdw1(0x%08x)\n",ptxdesc->txdw1); - DBG_88E("txdw2(0x%08x)\n",ptxdesc->txdw2); - DBG_88E("txdw3(0x%08x)\n",ptxdesc->txdw3); - DBG_88E("txdw4(0x%08x)\n",ptxdesc->txdw4); - DBG_88E("txdw5(0x%08x)\n",ptxdesc->txdw5); - DBG_88E("txdw6(0x%08x)\n",ptxdesc->txdw6); - DBG_88E("txdw7(0x%08x)\n",ptxdesc->txdw7); + DBG_88E("txdw0(0x%08x)\n", ptxdesc->txdw0); + DBG_88E("txdw1(0x%08x)\n", ptxdesc->txdw1); + DBG_88E("txdw2(0x%08x)\n", ptxdesc->txdw2); + DBG_88E("txdw3(0x%08x)\n", ptxdesc->txdw3); + DBG_88E("txdw4(0x%08x)\n", ptxdesc->txdw4); + DBG_88E("txdw5(0x%08x)\n", ptxdesc->txdw5); + DBG_88E("txdw6(0x%08x)\n", ptxdesc->txdw6); + DBG_88E("txdw7(0x%08x)\n", ptxdesc->txdw7); DBG_88E("=====================================\n"); } - } diff --git a/hal/rtl8188eu_led.c b/hal/rtl8188eu_led.c index 915444e..1cce948 100644 --- a/hal/rtl8188eu_led.c +++ b/hal/rtl8188eu_led.c @@ -24,114 +24,72 @@ #include /* LED object. */ -/* */ - -/* */ -/* Prototype of protected function. */ -/* */ - - -/* */ /* LED_819xUsb routines. */ -/* */ - -/* */ -/* Description: */ -/* Turn on LED according to LedPin specified. */ -/* */ -void SwLedOn(struct adapter *padapter, struct LED_871x * pLed) +/* Description: */ +/* Turn on LED according to LedPin specified. */ +void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) { u8 LedCfg; - if ( (padapter->bSurpriseRemoved == true) || ( padapter->bDriverStopped == true)) - { + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return; - } - LedCfg = rtw_read8(padapter, REG_LEDCFG2); - switch (pLed->LedPin) - { - case LED_PIN_LED0: - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ - break; - - case LED_PIN_LED1: - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT5); /* SW control led1 on. */ - break; - - default: - break; + switch (pLed->LedPin) { + case LED_PIN_LED0: + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ + break; + case LED_PIN_LED1: + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT5); /* SW control led1 on. */ + break; + default: + break; } - pLed->bLedOn = true; } - -/* */ -/* Description: */ -/* Turn off LED according to LedPin specified. */ -/* */ -void SwLedOff(struct adapter *padapter, struct LED_871x * pLed) +/* Description: */ +/* Turn off LED according to LedPin specified. */ +void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) { u8 LedCfg; struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - if ((padapter->bSurpriseRemoved == true) || ( padapter->bDriverStopped == true)) - { + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) goto exit; - } - LedCfg = rtw_read8(padapter, REG_LEDCFG2);/* 0x4E */ - switch (pLed->LedPin) - { - case LED_PIN_LED0: - if (pHalData->bLedOpenDrain == true) /* Open-drain arrangement for controlling the LED) */ - { - LedCfg &= 0x90; /* Set to software control. */ - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); - LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG); - LedCfg &= 0xFE; - rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); - } - else - { - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6)); - } - break; - - case LED_PIN_LED1: - LedCfg &= 0x0f; /* Set to software control. */ + switch (pLed->LedPin) { + case LED_PIN_LED0: + if (pHalData->bLedOpenDrain) { + /* Open-drain arrangement for controlling the LED) */ + LedCfg &= 0x90; /* Set to software control. */ rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); - break; - - default: - break; + LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG); + LedCfg &= 0xFE; + rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); + } else { + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6)); + } + break; + case LED_PIN_LED1: + LedCfg &= 0x0f; /* Set to software control. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); + break; + default: + break; } exit: pLed->bLedOn = false; - } -/* */ /* Interface to manipulate LED objects. */ -/* */ - - -/* */ /* Default LED behavior. */ -/* */ -/* */ -/* Description: */ -/* Initialize all LED_871x objects. */ -/* */ -void -rtl8188eu_InitSwLeds( - struct adapter *padapter - ) +/* Description: */ +/* Initialize all LED_871x objects. */ +void rtl8188eu_InitSwLeds(struct adapter *padapter) { struct led_priv *pledpriv = &(padapter->ledpriv); @@ -139,21 +97,15 @@ rtl8188eu_InitSwLeds( InitLed871x(padapter, &(pledpriv->SwLed0), LED_PIN_LED0); - InitLed871x(padapter,&(pledpriv->SwLed1), LED_PIN_LED1); + InitLed871x(padapter, &(pledpriv->SwLed1), LED_PIN_LED1); } - -/* */ -/* Description: */ -/* DeInitialize all LED_819xUsb objects. */ -/* */ -void -rtl8188eu_DeInitSwLeds( - struct adapter *padapter - ) +/* Description: */ +/* DeInitialize all LED_819xUsb objects. */ +void rtl8188eu_DeInitSwLeds(struct adapter *padapter) { struct led_priv *ledpriv = &(padapter->ledpriv); - DeInitLed871x( &(ledpriv->SwLed0) ); - DeInitLed871x( &(ledpriv->SwLed1) ); + DeInitLed871x(&(ledpriv->SwLed0)); + DeInitLed871x(&(ledpriv->SwLed1)); } diff --git a/hal/rtl8188eu_recv.c b/hal/rtl8188eu_recv.c index e12633e..cdac256 100644 --- a/hal/rtl8188eu_recv.c +++ b/hal/rtl8188eu_recv.c @@ -32,22 +32,20 @@ #include - void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf) { - precvbuf->transfer_len = 0; precvbuf->len = 0; precvbuf->ref_cnt = 0; - if (precvbuf->pbuf) - { - precvbuf->pdata = precvbuf->phead = precvbuf->ptail = precvbuf->pbuf; + if (precvbuf->pbuf) { + precvbuf->pdata = precvbuf->pbuf; + precvbuf->phead = precvbuf->pbuf; + precvbuf->ptail = precvbuf->pbuf; precvbuf->pend = precvbuf->pdata + MAX_RECVBUF_SZ; } - } int rtl8188eu_init_recv_priv(struct adapter *padapter) @@ -57,88 +55,68 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) struct recv_buf *precvbuf; tasklet_init(&precvpriv->recv_tasklet, - (void(*)(unsigned long))rtl8188eu_recv_tasklet, - (unsigned long)padapter); + (void(*)(unsigned long))rtl8188eu_recv_tasklet, + (unsigned long)padapter); /* init recv_buf */ _rtw_init_queue(&precvpriv->free_recv_buf_queue); - precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF *sizeof(struct recv_buf) + 4); - if (precvpriv->pallocated_recv_buf==NULL){ - res= _FAIL; - RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,("alloc recv_buf fail!\n")); + precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4); + if (precvpriv->pallocated_recv_buf == NULL) { + res = _FAIL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n")); goto exit; } - _rtw_memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF *sizeof(struct recv_buf) + 4); + _rtw_memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF * sizeof(struct recv_buf) + 4); precvpriv->precv_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(precvpriv->pallocated_recv_buf), 4); - precvbuf = (struct recv_buf*)precvpriv->precv_buf; + precvbuf = (struct recv_buf *)precvpriv->precv_buf; - for (i=0; i < NR_RECVBUFF ; i++) - { + for (i = 0; i < NR_RECVBUFF; i++) { _rtw_init_listhead(&precvbuf->list); - _rtw_spinlock_init(&precvbuf->recvbuf_lock); - precvbuf->alloc_sz = MAX_RECVBUF_SZ; - res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); - if (res==_FAIL) + if (res == _FAIL) break; - precvbuf->ref_cnt = 0; - precvbuf->adapter =padapter; - - - + precvbuf->adapter = padapter; precvbuf++; - } precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF; skb_queue_head_init(&precvpriv->rx_skb_queue); - { int i; - size_t tmpaddr=0; - size_t alignment=0; - struct sk_buff *pskb=NULL; + size_t tmpaddr = 0; + size_t alignment = 0; + struct sk_buff *pskb = NULL; skb_queue_head_init(&precvpriv->free_recv_skb_queue); - for (i=0; ipnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, GFP_KERNEL); - #endif - - if (pskb) - { +#endif + if (pskb) { pskb->dev = padapter->pnetdev; - tmpaddr = (size_t)pskb->data; alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); } - - pskb=NULL; - + pskb = NULL; } } - exit: - return res; - } -void rtl8188eu_free_recv_priv (struct adapter *padapter) +void rtl8188eu_free_recv_priv(struct adapter *padapter) { int i; struct recv_buf *precvbuf; @@ -146,14 +124,13 @@ void rtl8188eu_free_recv_priv (struct adapter *padapter) precvbuf = (struct recv_buf *)precvpriv->precv_buf; - for (i=0; i < NR_RECVBUFF ; i++) - { + for (i = 0; i < NR_RECVBUFF; i++) { rtw_os_recvbuf_resource_free(padapter, precvbuf); precvbuf++; } if (precvpriv->pallocated_recv_buf) - rtw_mfree(precvpriv->pallocated_recv_buf, NR_RECVBUFF *sizeof(struct recv_buf) + 4); + rtw_mfree(precvpriv->pallocated_recv_buf, NR_RECVBUFF * sizeof(struct recv_buf) + 4); if (skb_queue_len(&precvpriv->rx_skb_queue)) DBG_88E(KERN_WARNING "rx_skb_queue not empty\n"); diff --git a/hal/rtl8188eu_xmit.c b/hal/rtl8188eu_xmit.c index 7c22706..ab44ffc 100644 --- a/hal/rtl8188eu_xmit.c +++ b/hal/rtl8188eu_xmit.c @@ -26,65 +26,58 @@ #include #include -s32 rtl8188eu_init_xmit_priv(struct adapter *padapter) +s32 rtl8188eu_init_xmit_priv(struct adapter *adapt) { - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); tasklet_init(&pxmitpriv->xmit_tasklet, - (void(*)(unsigned long))rtl8188eu_xmit_tasklet, - (unsigned long)padapter); + (void(*)(unsigned long))rtl8188eu_xmit_tasklet, + (unsigned long)adapt); return _SUCCESS; } -void rtl8188eu_free_xmit_priv(struct adapter *padapter) +void rtl8188eu_free_xmit_priv(struct adapter *adapt) { } -static u8 urb_zero_packet_chk(struct adapter *padapter, int sz) +static u8 urb_zero_packet_chk(struct adapter *adapt, int sz) { - u8 blnSetTxDescOffset; - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - blnSetTxDescOffset = (((sz + TXDESC_SIZE) % pHalData->UsbBulkOutSize) ==0)?1:0; + u8 set_tx_desc_offset; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + set_tx_desc_offset = (((sz + TXDESC_SIZE) % haldata->UsbBulkOutSize) == 0) ? 1 : 0; - return blnSetTxDescOffset; + return set_tx_desc_offset; } static void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc) { - u16 *usPtr = (u16*)ptxdesc; - u32 count = 16; /* (32 bytes / 2 bytes per XOR) => 16 times */ - u32 index; - u16 checksum = 0; + u16 *usptr = (u16 *)ptxdesc; + u32 count = 16; /* (32 bytes / 2 bytes per XOR) => 16 times */ + u32 index; + u16 checksum = 0; - /* Clear first */ - ptxdesc->txdw7 &= cpu_to_le32(0xffff0000); + /* Clear first */ + ptxdesc->txdw7 &= cpu_to_le32(0xffff0000); - for (index = 0; index < count; index++) - checksum = checksum ^ le16_to_cpu(*(__le16 *)(usPtr + index)); - ptxdesc->txdw7 |= cpu_to_le32(0x0000ffff&checksum); + for (index = 0; index < count; index++) + checksum = checksum ^ le16_to_cpu(*(__le16 *)(usptr + index)); + ptxdesc->txdw7 |= cpu_to_le32(0x0000ffff & checksum); } -/* */ + /* Description: In normal chip, we should send some packet to Hw which will be used by Fw */ -/* in FW LPS mode. The function is to fill the Tx descriptor of this packets, then */ -/* Fw can tell Hw to send these packet derectly. */ -/* */ -void rtl8188e_fill_fake_txdesc( - struct adapter * padapter, - u8* pDesc, - u32 BufferLen, - u8 IsPsPoll, - u8 IsBTQosNull) +/* in FW LPS mode. The function is to fill the Tx descriptor of this packets, then */ +/* Fw can tell Hw to send these packet derectly. */ +void rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u8 ispspoll, u8 is_btqosnull) { struct tx_desc *ptxdesc; - /* Clear all status */ - ptxdesc = (struct tx_desc*)pDesc; - _rtw_memset(pDesc, 0, TXDESC_SIZE); + ptxdesc = (struct tx_desc *)desc; + _rtw_memset(desc, 0, TXDESC_SIZE); /* offset 0 */ - ptxdesc->txdw0 |= cpu_to_le32( OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */ + ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */ ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<txdw1 |= cpu_to_le32((QSLT_MGNT<txdw1 |= cpu_to_le32(NAVUSEHDR); - } - else - { + } else { ptxdesc->txdw4 |= cpu_to_le32(BIT(7)); /* Hw set sequence number */ - ptxdesc->txdw3 |= cpu_to_le32((8 <<28)); /* set bit3 to 1. Suugested by TimChen. 2009.12.29. */ + ptxdesc->txdw3 |= cpu_to_le32((8 << 28)); /* set bit3 to 1. Suugested by TimChen. 2009.12.29. */ } - if (true == IsBTQosNull) - { + if (is_btqosnull) ptxdesc->txdw2 |= cpu_to_le32(BIT(23)); /* BT NULL */ - } /* offset 16 */ ptxdesc->txdw4 |= cpu_to_le32(BIT(8));/* driver uses rate */ @@ -160,16 +148,16 @@ static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) *pdw |= cpu_to_le32(HW_RTS_EN); /* Set RTS BW */ if (pattrib->ht_en) { - *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40)? cpu_to_le32(BIT(27)):0; + *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0; if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) - *pdw |= cpu_to_le32((0x01<<28)&0x30000000); + *pdw |= cpu_to_le32((0x01 << 28) & 0x30000000); else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) - *pdw |= cpu_to_le32((0x02<<28)&0x30000000); + *pdw |= cpu_to_le32((0x02 << 28) & 0x30000000); else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) *pdw |= 0; else - *pdw |= cpu_to_le32((0x03<<28)&0x30000000); + *pdw |= cpu_to_le32((0x03 << 28) & 0x30000000); } } } @@ -177,40 +165,39 @@ static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw) { if (pattrib->ht_en) { - *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40)? cpu_to_le32(BIT(25)):0; + *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0; if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) - *pdw |= cpu_to_le32((0x01<ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) - *pdw |= cpu_to_le32((0x02<ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) *pdw |= 0; else - *pdw |= cpu_to_le32((0x03<padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + u8 data_rate, pwr_status, offset; + struct adapter *adapt = pxmitframe->padapter; + struct mlme_priv *pmlmepriv = &adapt->mlmepriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); struct tx_desc *ptxdesc = (struct tx_desc *)pmem; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); int bmcst = IS_MCAST(pattrib->ra); #ifdef CONFIG_P2P - struct wifidirect_info* pwdinfo = &padapter->wdinfo; + struct wifidirect_info *pwdinfo = &adapt->wdinfo; #endif /* CONFIG_P2P */ - if (padapter->registrypriv.mp_mode == 0) { - if ((!bagg_pkt) &&(urb_zero_packet_chk(padapter, sz)==0))/* sz %512) != 0 */ { + if (adapt->registrypriv.mp_mode == 0) { + if ((!bagg_pkt) && (urb_zero_packet_chk(adapt, sz) == 0)) { ptxdesc = (struct tx_desc *)(pmem+PACKET_OFFSET_SZ); pull = 1; } @@ -218,7 +205,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag _rtw_memset(ptxdesc, 0, sizeof(struct tx_desc)); - /* 4 offset 0 */ + /* 4 offset 0 */ ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); ptxdesc->txdw0 |= cpu_to_le32(sz & 0x0000ffff);/* update TXPKTSIZE */ @@ -226,12 +213,13 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag ptxdesc->txdw0 |= cpu_to_le32(((offset) << OFFSET_SHT) & 0x00ff0000);/* 32 bytes for TX Desc */ - if (bmcst) ptxdesc->txdw0 |= cpu_to_le32(BMC); + if (bmcst) + ptxdesc->txdw0 |= cpu_to_le32(BMC); - if (padapter->registrypriv.mp_mode == 0) { - if (!bagg_pkt){ - if ((pull) && (pxmitframe->pkt_offset>0)) - pxmitframe->pkt_offset = pxmitframe->pkt_offset -1; + if (adapt->registrypriv.mp_mode == 0) { + if (!bagg_pkt) { + if ((pull) && (pxmitframe->pkt_offset > 0)) + pxmitframe->pkt_offset = pxmitframe->pkt_offset - 1; } } @@ -242,49 +230,41 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag /* driver uses rate */ ptxdesc->txdw4 |= cpu_to_le32(USERATE);/* rate control always by driver */ - if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) - { - + if ((pxmitframe->frame_tag & 0x0f) == DATA_FRAMETAG) { /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id&0x3F); + ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3F); qsel = (uint)(pattrib->qsel & 0x0000001f); ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); - ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid<< RATE_ID_SHT) & 0x000F0000); + ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000F0000); fill_txdesc_sectype(pattrib, ptxdesc); - if (pattrib->ampdu_en==true){ + if (pattrib->ampdu_en) { ptxdesc->txdw2 |= cpu_to_le32(AGG_EN);/* AGG EN */ - ptxdesc->txdw6 = cpu_to_le32(0x6666f800); - } - else{ + } else { ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);/* AGG BK */ } /* offset 8 */ - /* offset 12 */ - ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum<< SEQ_SHT)&0x0FFF0000); - + ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0FFF0000); /* offset 16 , offset 20 */ if (pattrib->qos_en) ptxdesc->txdw4 |= cpu_to_le32(QOS);/* QoS */ /* offset 20 */ - if (pxmitframe->agg_num > 1){ + if (pxmitframe->agg_num > 1) ptxdesc->txdw5 |= cpu_to_le32((pxmitframe->agg_num << USB_TXAGG_NUM_SHT) & 0xFF000000); - } if ((pattrib->ether_type != 0x888e) && (pattrib->ether_type != 0x0806) && (pattrib->ether_type != 0x88b4) && - (pattrib->dhcp_pkt != 1)) - { + (pattrib->dhcp_pkt != 1)) { /* Non EAP & ARP & DHCP type data packet */ fill_txdesc_vcs(pattrib, &ptxdesc->txdw4); @@ -293,38 +273,31 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag ptxdesc->txdw4 |= cpu_to_le32(0x00000008);/* RTS Rate=24M */ ptxdesc->txdw5 |= cpu_to_le32(0x0001ff00);/* DATA/RTS Rate FB LMT */ - if (pattrib->ht_en){ - if ( ODM_RA_GetShortGI_8188E(&pHalData->odmpriv,pattrib->mac_id)) + if (pattrib->ht_en) { + if (ODM_RA_GetShortGI_8188E(&haldata->odmpriv, pattrib->mac_id)) ptxdesc->txdw5 |= cpu_to_le32(SGI);/* SGI */ } - - data_rate =ODM_RA_GetDecisionRate_8188E(&pHalData->odmpriv,pattrib->mac_id); + data_rate = ODM_RA_GetDecisionRate_8188E(&haldata->odmpriv, pattrib->mac_id); ptxdesc->txdw5 |= cpu_to_le32(data_rate & 0x3F); - - pwr_status = ODM_RA_GetHwPwrStatus_8188E(&pHalData->odmpriv,pattrib->mac_id); - ptxdesc->txdw4 |=cpu_to_le32( (pwr_status & 0x7)<< PWR_STATUS_SHT); + pwr_status = ODM_RA_GetHwPwrStatus_8188E(&haldata->odmpriv, pattrib->mac_id); + ptxdesc->txdw4 |= cpu_to_le32((pwr_status & 0x7) << PWR_STATUS_SHT); } else { /* EAP data packet and ARP packet and DHCP. */ /* Use the 1M data rate to send the EAP/ARP packet. */ /* This will maybe make the handshake smooth. */ - ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);/* AGG BK */ - if (pmlmeinfo->preamble_mode == PREAMBLE_SHORT) ptxdesc->txdw4 |= cpu_to_le32(BIT(24));/* DATA_SHORT */ - ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); } - } else if ((pxmitframe->frame_tag&0x0f)== MGNT_FRAMETAG) { - + } else if ((pxmitframe->frame_tag&0x0f) == MGNT_FRAMETAG) { /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id&0x3f); + ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3f); qsel = (uint)(pattrib->qsel&0x0000001f); - ptxdesc->txdw1 |= cpu_to_le32((qsel<txdw1 |= cpu_to_le32((pattrib->raid<< RATE_ID_SHT) & 0x000f0000); + ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); + ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000f0000); /* offset 8 */ /* CCX-TXRPT ack for xmit mgmt frames. */ @@ -336,30 +309,24 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag /* offset 20 */ ptxdesc->txdw5 |= cpu_to_le32(RTY_LMT_EN);/* retry limit enable */ - if (pattrib->retry_ctrl == true) + if (pattrib->retry_ctrl) ptxdesc->txdw5 |= cpu_to_le32(0x00180000);/* retry limit = 6 */ else ptxdesc->txdw5 |= cpu_to_le32(0x00300000);/* retry limit = 12 */ ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); - } - else if ((pxmitframe->frame_tag&0x0f) == TXAGG_FRAMETAG) - { + } else if ((pxmitframe->frame_tag&0x0f) == TXAGG_FRAMETAG) { DBG_88E("pxmitframe->frame_tag == TXAGG_FRAMETAG\n"); - } - else if (((pxmitframe->frame_tag&0x0f) == MP_FRAMETAG) && - (padapter->registrypriv.mp_mode == 1)) - { - fill_txdesc_for_mp(padapter, ptxdesc); - } - else - { + } else if (((pxmitframe->frame_tag&0x0f) == MP_FRAMETAG) && + (adapt->registrypriv.mp_mode == 1)) { + fill_txdesc_for_mp(adapt, ptxdesc); + } else { DBG_88E("pxmitframe->frame_tag = %d\n", pxmitframe->frame_tag); /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32((4)&0x3f);/* CAM_ID(MAC_ID) */ + ptxdesc->txdw1 |= cpu_to_le32((4) & 0x3f);/* CAM_ID(MAC_ID) */ - ptxdesc->txdw1 |= cpu_to_le32((6<< RATE_ID_SHT) & 0x000f0000);/* raid */ + ptxdesc->txdw1 |= cpu_to_le32((6 << RATE_ID_SHT) & 0x000f0000);/* raid */ /* offset 8 */ @@ -378,87 +345,74 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz ,u8 bag /* (2) Enable HW SEQ control for beacon packet, because we use Hw beacon. */ /* (3) Use HW Qos SEQ to control the seq num of Ext port non-Qos packets. */ /* 2010.06.23. Added by tynli. */ - if (!pattrib->qos_en) - { + if (!pattrib->qos_en) { ptxdesc->txdw3 |= cpu_to_le32(EN_HWSEQ); /* Hw set sequence number */ ptxdesc->txdw4 |= cpu_to_le32(HW_SSN); /* Hw set sequence number */ - } - ODM_SetTxAntByTxInfo_88E(&pHalData->odmpriv, pmem, pattrib->mac_id); + ODM_SetTxAntByTxInfo_88E(&haldata->odmpriv, pmem, pattrib->mac_id); rtl8188eu_cal_txdesc_chksum(ptxdesc); - _dbg_dump_tx_info(padapter,pxmitframe->frame_tag,ptxdesc); + _dbg_dump_tx_info(adapt, pxmitframe->frame_tag, ptxdesc); return pull; } /* for non-agg data frame or management frame */ -static s32 rtw_dump_xframe(struct adapter *padapter, struct xmit_frame *pxmitframe) +static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) { s32 ret = _SUCCESS; s32 inner_ret = _SUCCESS; - int t, sz, w_sz, pull=0; + int t, sz, w_sz, pull = 0; u8 *mem_addr; u32 ff_hwaddr; struct xmit_buf *pxmitbuf = pxmitframe->pxmitbuf; struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + struct security_priv *psecuritypriv = &adapt->securitypriv; if ((pxmitframe->frame_tag == DATA_FRAMETAG) && (pxmitframe->attrib.ether_type != 0x0806) && (pxmitframe->attrib.ether_type != 0x888e) && (pxmitframe->attrib.ether_type != 0x88b4) && (pxmitframe->attrib.dhcp_pkt != 1)) - { - rtw_issue_addbareq_cmd(padapter, pxmitframe); - } + rtw_issue_addbareq_cmd(adapt, pxmitframe); mem_addr = pxmitframe->buf_addr; - RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("rtw_dump_xframe()\n")); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_dump_xframe()\n")); - for (t = 0; t < pattrib->nr_frags; t++) - { + for (t = 0; t < pattrib->nr_frags; t++) { if (inner_ret != _SUCCESS && ret == _SUCCESS) ret = _FAIL; - if (t != (pattrib->nr_frags - 1)) - { - RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("pattrib->nr_frags=%d\n", pattrib->nr_frags)); + if (t != (pattrib->nr_frags - 1)) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("pattrib->nr_frags=%d\n", pattrib->nr_frags)); sz = pxmitpriv->frag_len; sz = sz - 4 - (psecuritypriv->sw_encrypt ? 0 : pattrib->icv_len); - } - else /* no frag */ - { + } else { + /* no frag */ sz = pattrib->last_txcmdsz; } pull = update_txdesc(pxmitframe, mem_addr, sz, false); - if (pull) - { + if (pull) { mem_addr += PACKET_OFFSET_SZ; /* pull txdesc head */ - pxmitframe->buf_addr = mem_addr; - w_sz = sz + TXDESC_SIZE; - } - else - { + } else { w_sz = sz + TXDESC_SIZE + PACKET_OFFSET_SZ; } ff_hwaddr = rtw_get_ff_hwaddr(pxmitframe); - inner_ret = rtw_write_port(padapter, ff_hwaddr, w_sz, (unsigned char*)pxmitbuf); + inner_ret = rtw_write_port(adapt, ff_hwaddr, w_sz, (unsigned char *)pxmitbuf); - rtw_count_tx_stats(padapter, pxmitframe, sz); + rtw_count_tx_stats(adapt, pxmitframe, sz); - RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("rtw_write_port, w_sz=%d\n", w_sz)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_write_port, w_sz=%d\n", w_sz)); mem_addr += w_sz; mem_addr = (u8 *)RND4(((size_t)(mem_addr))); - } rtw_free_xmitframe(pxmitpriv, pxmitframe); @@ -473,7 +427,7 @@ static u32 xmitframe_need_length(struct xmit_frame *pxmitframe) { struct pkt_attrib *pattrib = &pxmitframe->attrib; - u32 len = 0; + u32 len = 0; /* no consider fragement */ len = pattrib->hdrlen + pattrib->iv_len + @@ -481,15 +435,15 @@ static u32 xmitframe_need_length(struct xmit_frame *pxmitframe) pattrib->pktlen + ((pattrib->bswenc) ? pattrib->icv_len : 0); - if (pattrib->encrypt ==_TKIP_) + if (pattrib->encrypt == _TKIP_) len += 8; return len; } -s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); struct xmit_frame *pxmitframe = NULL; struct xmit_frame *pfirstframe = NULL; @@ -498,29 +452,27 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, struct xmit_priv *pxm struct sta_info *psta = NULL; struct tx_servq *ptxservq = NULL; - unsigned long irqL; + unsigned long irql; struct list_head *xmitframe_plist = NULL, *xmitframe_phead = NULL; - u32 pbuf; /* next pkt address */ - u32 pbuf_tail; /* last pkt tail */ - u32 len; /* packet length, except TXDESC_SIZE and PKT_OFFSET */ + u32 pbuf; /* next pkt address */ + u32 pbuf_tail; /* last pkt tail */ + u32 len; /* packet length, except TXDESC_SIZE and PKT_OFFSET */ - u32 bulkSize = pHalData->UsbBulkOutSize; - u8 descCount; - u32 bulkPtr; + u32 bulksize = haldata->UsbBulkOutSize; + u8 desc_cnt; + u32 bulkptr; /* dump frame variable */ u32 ff_hwaddr; RT_TRACE(_module_rtl8192c_xmit_c_, _drv_info_, ("+xmitframe_complete\n")); - /* check xmitbuffer is ok */ if (pxmitbuf == NULL) { pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (pxmitbuf == NULL){ + if (pxmitbuf == NULL) return false; - } } /* 3 1. pick up first frame */ @@ -541,75 +493,70 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, struct xmit_priv *pxm pxmitframe->agg_num = 1; /* alloc xmitframe should assign to 1. */ pxmitframe->pkt_offset = 1; /* first frame of aggregation, reserve offset */ - rtw_xmitframe_coalesce(padapter, pxmitframe->pkt, pxmitframe); + rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); /* always return ndis_packet after rtw_xmitframe_coalesce */ - rtw_os_xmit_complete(padapter, pxmitframe); + rtw_os_xmit_complete(adapt, pxmitframe); break; } while (1); /* 3 2. aggregate same priority and same DA(AP or STA) frames */ pfirstframe = pxmitframe; - len = xmitframe_need_length(pfirstframe) + TXDESC_SIZE+(pfirstframe->pkt_offset*PACKET_OFFSET_SZ); + len = xmitframe_need_length(pfirstframe) + TXDESC_SIZE + (pfirstframe->pkt_offset*PACKET_OFFSET_SZ); pbuf_tail = len; pbuf = _RND8(pbuf_tail); /* check pkt amount in one bulk */ - descCount = 0; - bulkPtr = bulkSize; - if (pbuf < bulkPtr) - descCount++; - else { - descCount = 0; - bulkPtr = ((pbuf / bulkSize) + 1) * bulkSize; /* round to next bulkSize */ + desc_cnt = 0; + bulkptr = bulksize; + if (pbuf < bulkptr) { + desc_cnt++; + } else { + desc_cnt = 0; + bulkptr = ((pbuf / bulksize) + 1) * bulksize; /* round to next bulksize */ } /* dequeue same priority packet from station tx queue */ psta = pfirstframe->attrib.psta; switch (pfirstframe->attrib.priority) { - case 1: - case 2: - ptxservq = &(psta->sta_xmitpriv.bk_q); - phwxmit = pxmitpriv->hwxmits + 3; - break; - - case 4: - case 5: - ptxservq = &(psta->sta_xmitpriv.vi_q); - phwxmit = pxmitpriv->hwxmits + 1; - break; - - case 6: - case 7: - ptxservq = &(psta->sta_xmitpriv.vo_q); - phwxmit = pxmitpriv->hwxmits; - break; - - case 0: - case 3: - default: - ptxservq = &(psta->sta_xmitpriv.be_q); - phwxmit = pxmitpriv->hwxmits + 2; - break; + case 1: + case 2: + ptxservq = &(psta->sta_xmitpriv.bk_q); + phwxmit = pxmitpriv->hwxmits + 3; + break; + case 4: + case 5: + ptxservq = &(psta->sta_xmitpriv.vi_q); + phwxmit = pxmitpriv->hwxmits + 1; + break; + case 6: + case 7: + ptxservq = &(psta->sta_xmitpriv.vo_q); + phwxmit = pxmitpriv->hwxmits; + break; + case 0: + case 3: + default: + ptxservq = &(psta->sta_xmitpriv.be_q); + phwxmit = pxmitpriv->hwxmits + 2; + break; } - _enter_critical_bh(&pxmitpriv->lock, &irqL); + _enter_critical_bh(&pxmitpriv->lock, &irql); xmitframe_phead = get_list_head(&ptxservq->sta_pending); xmitframe_plist = get_next(xmitframe_phead); - while (rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist) == false) - { + while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); pxmitframe->agg_num = 0; /* not first frame of aggregation */ pxmitframe->pkt_offset = 0; /* not first frame of aggregation, no need to reserve offset */ - len = xmitframe_need_length(pxmitframe) + TXDESC_SIZE +(pxmitframe->pkt_offset*PACKET_OFFSET_SZ); + len = xmitframe_need_length(pxmitframe) + TXDESC_SIZE + (pxmitframe->pkt_offset*PACKET_OFFSET_SZ); - if (_RND8(pbuf + len) > MAX_XMITBUF_SZ) - { + if (_RND8(pbuf + len) > MAX_XMITBUF_SZ) { pxmitframe->agg_num = 1; pxmitframe->pkt_offset = 1; break; @@ -620,12 +567,12 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, struct xmit_priv *pxm pxmitframe->buf_addr = pxmitbuf->pbuf + pbuf; - rtw_xmitframe_coalesce(padapter, pxmitframe->pkt, pxmitframe); + rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); /* always return ndis_packet after rtw_xmitframe_coalesce */ - rtw_os_xmit_complete(padapter, pxmitframe); + rtw_os_xmit_complete(adapt, pxmitframe); /* (len - TXDESC_SIZE) == pxmitframe->attrib.last_txcmdsz */ - update_txdesc(pxmitframe, pxmitframe->buf_addr, pxmitframe->attrib.last_txcmdsz,true); + update_txdesc(pxmitframe, pxmitframe->buf_addr, pxmitframe->attrib.last_txcmdsz, true); /* don't need xmitframe any more */ rtw_free_xmitframe(pxmitpriv, pxmitframe); @@ -634,72 +581,63 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, struct xmit_priv *pxm pbuf_tail = pbuf + len; pbuf = _RND8(pbuf_tail); - pfirstframe->agg_num++; if (MAX_TX_AGG_PACKET_NUMBER == pfirstframe->agg_num) break; - if (pbuf < bulkPtr) { - descCount++; - if (descCount == pHalData->UsbTxAggDescNum) + if (pbuf < bulkptr) { + desc_cnt++; + if (desc_cnt == haldata->UsbTxAggDescNum) break; } else { - descCount = 0; - bulkPtr = ((pbuf / bulkSize) + 1) * bulkSize; + desc_cnt = 0; + bulkptr = ((pbuf / bulksize) + 1) * bulksize; } - }/* end while ( aggregate same priority and same DA(AP or STA) frames) */ - + } /* end while (aggregate same priority and same DA(AP or STA) frames) */ if (_rtw_queue_empty(&ptxservq->sta_pending) == true) rtw_list_delete(&ptxservq->tx_pending); - _exit_critical_bh(&pxmitpriv->lock, &irqL); + _exit_critical_bh(&pxmitpriv->lock, &irql); if ((pfirstframe->attrib.ether_type != 0x0806) && (pfirstframe->attrib.ether_type != 0x888e) && (pfirstframe->attrib.ether_type != 0x88b4) && (pfirstframe->attrib.dhcp_pkt != 1)) - { - rtw_issue_addbareq_cmd(padapter, pfirstframe); - } + rtw_issue_addbareq_cmd(adapt, pfirstframe); /* 3 3. update first frame txdesc */ - if ((pbuf_tail % bulkSize) == 0) { + if ((pbuf_tail % bulksize) == 0) { /* remove pkt_offset */ pbuf_tail -= PACKET_OFFSET_SZ; pfirstframe->buf_addr += PACKET_OFFSET_SZ; pfirstframe->pkt_offset--; } - update_txdesc(pfirstframe, pfirstframe->buf_addr, pfirstframe->attrib.last_txcmdsz,true); + update_txdesc(pfirstframe, pfirstframe->buf_addr, pfirstframe->attrib.last_txcmdsz, true); /* 3 4. write xmit buffer to USB FIFO */ ff_hwaddr = rtw_get_ff_hwaddr(pfirstframe); - rtw_write_port(padapter, ff_hwaddr, pbuf_tail, (u8*)pxmitbuf); - + rtw_write_port(adapt, ff_hwaddr, pbuf_tail, (u8 *)pxmitbuf); /* 3 5. update statisitc */ pbuf_tail -= (pfirstframe->agg_num * TXDESC_SIZE); pbuf_tail -= (pfirstframe->pkt_offset * PACKET_OFFSET_SZ); - - rtw_count_tx_stats(padapter, pfirstframe, pbuf_tail); + rtw_count_tx_stats(adapt, pfirstframe, pbuf_tail); rtw_free_xmitframe(pxmitpriv, pfirstframe); return true; } -static s32 xmitframe_direct(struct adapter *padapter, struct xmit_frame *pxmitframe) +static s32 xmitframe_direct(struct adapter *adapt, struct xmit_frame *pxmitframe) { s32 res = _SUCCESS; - res = rtw_xmitframe_coalesce(padapter, pxmitframe->pkt, pxmitframe); - if (res == _SUCCESS) { - rtw_dump_xframe(padapter, pxmitframe); - } - else{ - DBG_88E("==> %s xmitframe_coalsece failed\n",__func__); - } - + res = rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); + if (res == _SUCCESS) + rtw_dump_xframe(adapt, pxmitframe); + else + DBG_88E("==> %s xmitframe_coalsece failed\n", __func__); return res; } @@ -708,22 +646,19 @@ static s32 xmitframe_direct(struct adapter *padapter, struct xmit_frame *pxmitfr * true dump packet directly * false enqueue packet */ -static s32 pre_xmitframe(struct adapter *padapter, struct xmit_frame *pxmitframe) +static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe) { - unsigned long irqL; + unsigned long irql; s32 res; struct xmit_buf *pxmitbuf = NULL; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &adapt->mlmepriv; - _enter_critical_bh(&pxmitpriv->lock, &irqL); + _enter_critical_bh(&pxmitpriv->lock, &irql); - if (rtw_txframes_sta_ac_pending(padapter, pattrib) > 0) - { + if (rtw_txframes_sta_ac_pending(adapt, pattrib) > 0) goto enqueue; - } - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) goto enqueue; @@ -732,13 +667,13 @@ static s32 pre_xmitframe(struct adapter *padapter, struct xmit_frame *pxmitframe if (pxmitbuf == NULL) goto enqueue; - _exit_critical_bh(&pxmitpriv->lock, &irqL); + _exit_critical_bh(&pxmitpriv->lock, &irql); pxmitframe->pxmitbuf = pxmitbuf; pxmitframe->buf_addr = pxmitbuf->pbuf; pxmitbuf->priv_data = pxmitframe; - if (xmitframe_direct(padapter, pxmitframe) != _SUCCESS) { + if (xmitframe_direct(adapt, pxmitframe) != _SUCCESS) { rtw_free_xmitbuf(pxmitpriv, pxmitbuf); rtw_free_xmitframe(pxmitpriv, pxmitframe); } @@ -746,8 +681,8 @@ static s32 pre_xmitframe(struct adapter *padapter, struct xmit_frame *pxmitframe return true; enqueue: - res = rtw_xmitframe_enqueue(padapter, pxmitframe); - _exit_critical_bh(&pxmitpriv->lock, &irqL); + res = rtw_xmitframe_enqueue(adapt, pxmitframe); + _exit_critical_bh(&pxmitpriv->lock, &irql); if (res != _SUCCESS) { RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("pre_xmitframe: enqueue xmitframe fail\n")); @@ -762,9 +697,9 @@ enqueue: return false; } -s32 rtl8188eu_mgnt_xmit(struct adapter *padapter, struct xmit_frame *pmgntframe) +s32 rtl8188eu_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe) { - return rtw_dump_xframe(padapter, pmgntframe); + return rtw_dump_xframe(adapt, pmgntframe); } /* @@ -772,7 +707,7 @@ s32 rtl8188eu_mgnt_xmit(struct adapter *padapter, struct xmit_frame *pmgntframe) * true dump packet directly ok * false temporary can't transmit packets to hardware */ -s32 rtl8188eu_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe) +s32 rtl8188eu_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) { - return pre_xmitframe(padapter, pxmitframe); + return pre_xmitframe(adapt, pxmitframe); } diff --git a/hal/usb_halinit.c b/hal/usb_halinit.c index edba202..44438a7 100644 --- a/hal/usb_halinit.c +++ b/hal/usb_halinit.c @@ -34,313 +34,261 @@ #define HAL_BB_ENABLE 1 #define HAL_RF_ENABLE 1 -static void -_ConfigNormalChipOutEP_8188E( - struct adapter * pAdapter, - u8 NumOutPipe - ) +static void _ConfigNormalChipOutEP_8188E(struct adapter *adapt, u8 NumOutPipe) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - - switch (NumOutPipe){ - case 3: - pHalData->OutEpQueueSel=TX_SELE_HQ| TX_SELE_LQ|TX_SELE_NQ; - pHalData->OutEpNumber=3; - break; - case 2: - pHalData->OutEpQueueSel=TX_SELE_HQ| TX_SELE_NQ; - pHalData->OutEpNumber=2; - break; - case 1: - pHalData->OutEpQueueSel=TX_SELE_HQ; - pHalData->OutEpNumber=1; - break; - default: - break; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + switch (NumOutPipe) { + case 3: + haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ | TX_SELE_NQ; + haldata->OutEpNumber = 3; + break; + case 2: + haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_NQ; + haldata->OutEpNumber = 2; + break; + case 1: + haldata->OutEpQueueSel = TX_SELE_HQ; + haldata->OutEpNumber = 1; + break; + default: + break; } - DBG_88E("%s OutEpQueueSel(0x%02x), OutEpNumber(%d)\n",__func__,pHalData->OutEpQueueSel,pHalData->OutEpNumber ); - + DBG_88E("%s OutEpQueueSel(0x%02x), OutEpNumber(%d)\n", __func__, haldata->OutEpQueueSel, haldata->OutEpNumber); } -static bool HalUsbSetQueuePipeMapping8188EUsb( - struct adapter * pAdapter, - u8 NumInPipe, - u8 NumOutPipe - ) +static bool HalUsbSetQueuePipeMapping8188EUsb(struct adapter *adapt, u8 NumInPipe, u8 NumOutPipe) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); bool result = false; - _ConfigNormalChipOutEP_8188E(pAdapter, NumOutPipe); + _ConfigNormalChipOutEP_8188E(adapt, NumOutPipe); /* Normal chip with one IN and one OUT doesn't have interrupt IN EP. */ - if (1 == pHalData->OutEpNumber){ - if (1 != NumInPipe){ + if (1 == haldata->OutEpNumber) { + if (1 != NumInPipe) return result; - } } /* All config other than above support one Bulk IN and one Interrupt IN. */ - result = Hal_MappingOutPipe(pAdapter, NumOutPipe); + result = Hal_MappingOutPipe(adapt, NumOutPipe); return result; - } -static void rtl8188eu_interface_configure(struct adapter *padapter) +static void rtl8188eu_interface_configure(struct adapter *adapt) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt); - if (pdvobjpriv->ishighspeed == true) - { - pHalData->UsbBulkOutSize = USB_HIGH_SPEED_BULK_SIZE;/* 512 bytes */ - } + if (pdvobjpriv->ishighspeed) + haldata->UsbBulkOutSize = USB_HIGH_SPEED_BULK_SIZE;/* 512 bytes */ else - { - pHalData->UsbBulkOutSize = USB_FULL_SPEED_BULK_SIZE;/* 64 bytes */ - } + haldata->UsbBulkOutSize = USB_FULL_SPEED_BULK_SIZE;/* 64 bytes */ - pHalData->interfaceIndex = pdvobjpriv->InterfaceNumber; + haldata->interfaceIndex = pdvobjpriv->InterfaceNumber; - pHalData->UsbTxAggMode = 1; - pHalData->UsbTxAggDescNum = 0x6; /* only 4 bits */ + haldata->UsbTxAggMode = 1; + haldata->UsbTxAggDescNum = 0x6; /* only 4 bits */ - pHalData->UsbRxAggMode = USB_RX_AGG_DMA;/* USB_RX_AGG_DMA; */ - pHalData->UsbRxAggBlockCount = 8; /* unit : 512b */ - pHalData->UsbRxAggBlockTimeout = 0x6; - pHalData->UsbRxAggPageCount = 48; /* uint :128 b 0x0A; 10 = MAX_RX_DMA_BUFFER_SIZE/2/pHalData->UsbBulkOutSize */ - pHalData->UsbRxAggPageTimeout = 0x4; /* 6, absolute time = 34ms/(2^6) */ + haldata->UsbRxAggMode = USB_RX_AGG_DMA;/* USB_RX_AGG_DMA; */ + haldata->UsbRxAggBlockCount = 8; /* unit : 512b */ + haldata->UsbRxAggBlockTimeout = 0x6; + haldata->UsbRxAggPageCount = 48; /* uint :128 b 0x0A; 10 = MAX_RX_DMA_BUFFER_SIZE/2/haldata->UsbBulkOutSize */ + haldata->UsbRxAggPageTimeout = 0x4; /* 6, absolute time = 34ms/(2^6) */ - HalUsbSetQueuePipeMapping8188EUsb(padapter, + HalUsbSetQueuePipeMapping8188EUsb(adapt, pdvobjpriv->RtNumInPipes, pdvobjpriv->RtNumOutPipes); - } -static u32 rtl8188eu_InitPowerOn(struct adapter *padapter) +static u32 rtl8188eu_InitPowerOn(struct adapter *adapt) { u16 value16; /* HW Power on sequence */ - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - if (true == pHalData->bMacPwrCtrlOn) + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + if (haldata->bMacPwrCtrlOn) return _SUCCESS; - if (!HalPwrSeqCmdParsing(padapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_PWR_ON_FLOW)) - { + if (!HalPwrSeqCmdParsing(adapt, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_PWR_ON_FLOW)) { DBG_88E(KERN_ERR "%s: run power on flow fail\n", __func__); return _FAIL; } /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ /* Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ - rtw_write16(padapter, REG_CR, 0x00); /* suggseted by zhouzhou, by page, 20111230 */ - + rtw_write16(adapt, REG_CR, 0x00); /* suggseted by zhouzhou, by page, 20111230 */ /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ - value16 = rtw_read16(padapter, REG_CR); + value16 = rtw_read16(adapt, REG_CR); value16 |= (HCI_TXDMA_EN | HCI_RXDMA_EN | TXDMA_EN | RXDMA_EN | PROTOCOL_EN | SCHEDULE_EN | ENSEC | CALTMR_EN); /* for SDIO - Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ - rtw_write16(padapter, REG_CR, value16); - pHalData->bMacPwrCtrlOn = true; + rtw_write16(adapt, REG_CR, value16); + haldata->bMacPwrCtrlOn = true; return _SUCCESS; - } - -static void _dbg_dump_macreg(struct adapter *padapter) +static void _dbg_dump_macreg(struct adapter *adapt) { u32 offset = 0; u32 val32 = 0; - u32 index =0 ; - for (index=0;index<64;index++) - { + u32 index = 0; + for (index = 0; index < 64; index++) { offset = index*4; - val32 = rtw_read32(padapter,offset); - DBG_88E("offset : 0x%02x ,val:0x%08x\n",offset,val32); + val32 = rtw_read32(adapt, offset); + DBG_88E("offset : 0x%02x ,val:0x%08x\n", offset, val32); } } - -static void _InitPABias(struct adapter *padapter) +static void _InitPABias(struct adapter *adapt) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - u8 pa_setting; - bool is92C = IS_92C_SERIAL(pHalData->VersionID); + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + u8 pa_setting; + bool is92C = IS_92C_SERIAL(haldata->VersionID); /* FIXED PA current issue */ - pa_setting = EFUSE_Read1Byte(padapter, 0x1FA); + pa_setting = EFUSE_Read1Byte(adapt, 0x1FA); - if (!(pa_setting & BIT0)) - { - PHY_SetRFReg(padapter, RF_PATH_A, 0x15, 0x0FFFFF, 0x0F406); - PHY_SetRFReg(padapter, RF_PATH_A, 0x15, 0x0FFFFF, 0x4F406); - PHY_SetRFReg(padapter, RF_PATH_A, 0x15, 0x0FFFFF, 0x8F406); - PHY_SetRFReg(padapter, RF_PATH_A, 0x15, 0x0FFFFF, 0xCF406); + if (!(pa_setting & BIT0)) { + PHY_SetRFReg(adapt, RF_PATH_A, 0x15, 0x0FFFFF, 0x0F406); + PHY_SetRFReg(adapt, RF_PATH_A, 0x15, 0x0FFFFF, 0x4F406); + PHY_SetRFReg(adapt, RF_PATH_A, 0x15, 0x0FFFFF, 0x8F406); + PHY_SetRFReg(adapt, RF_PATH_A, 0x15, 0x0FFFFF, 0xCF406); } - if (!(pa_setting & BIT1) && is92C) - { - PHY_SetRFReg(padapter,RF_PATH_B, 0x15, 0x0FFFFF, 0x0F406); - PHY_SetRFReg(padapter,RF_PATH_B, 0x15, 0x0FFFFF, 0x4F406); - PHY_SetRFReg(padapter,RF_PATH_B, 0x15, 0x0FFFFF, 0x8F406); - PHY_SetRFReg(padapter,RF_PATH_B, 0x15, 0x0FFFFF, 0xCF406); + if (!(pa_setting & BIT1) && is92C) { + PHY_SetRFReg(adapt, RF_PATH_B, 0x15, 0x0FFFFF, 0x0F406); + PHY_SetRFReg(adapt, RF_PATH_B, 0x15, 0x0FFFFF, 0x4F406); + PHY_SetRFReg(adapt, RF_PATH_B, 0x15, 0x0FFFFF, 0x8F406); + PHY_SetRFReg(adapt, RF_PATH_B, 0x15, 0x0FFFFF, 0xCF406); } - if (!(pa_setting & BIT4)) - { - pa_setting = rtw_read8(padapter, 0x16); + if (!(pa_setting & BIT4)) { + pa_setting = rtw_read8(adapt, 0x16); pa_setting &= 0x0F; - rtw_write8(padapter, 0x16, pa_setting | 0x80); - rtw_write8(padapter, 0x16, pa_setting | 0x90); + rtw_write8(adapt, 0x16, pa_setting | 0x80); + rtw_write8(adapt, 0x16, pa_setting | 0x90); } } #ifdef CONFIG_BT_COEXIST -static void _InitBTCoexist(struct adapter *padapter) +static void _InitBTCoexist(struct adapter *adapt) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct btcoexist_priv *pbtpriv = &(pHalData->bt_coexist); + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct btcoexist_priv *pbtpriv = &(haldata->bt_coexist); u8 u1Tmp; - if (pbtpriv->BT_Coexist && pbtpriv->BT_CoexistType == BT_CSR_BC4) - { - - if (padapter->registrypriv.mp_mode == 0) - { - if (pbtpriv->BT_Ant_isolation) - { - rtw_write8( padapter,REG_GPIO_MUXCFG, 0xa0); - DBG_88E("BT write 0x%x = 0x%x\n", REG_GPIO_MUXCFG, 0xa0); + if (pbtpriv->BT_Coexist && pbtpriv->BT_CoexistType == BT_CSR_BC4) { + if (adapt->registrypriv.mp_mode == 0) { + if (pbtpriv->BT_Ant_isolation) { + rtw_write8(adapt, REG_GPIO_MUXCFG, 0xa0); + DBG_88E("BT write 0x%x = 0x%x\n", REG_GPIO_MUXCFG, 0xa0); + } } - } - u1Tmp = rtw_read8(padapter, 0x4fd) & BIT0; - u1Tmp = u1Tmp | - ((pbtpriv->BT_Ant_isolation==1)?0:BIT1) | - ((pbtpriv->BT_Service==BT_SCO)?0:BIT2); - rtw_write8( padapter, 0x4fd, u1Tmp); - DBG_88E("BT write 0x%x = 0x%x for non-isolation\n", 0x4fd, u1Tmp); + u1Tmp = rtw_read8(adapt, 0x4fd) & BIT0; + u1Tmp = u1Tmp | + ((pbtpriv->BT_Ant_isolation == 1) ? 0 : BIT1) | + ((pbtpriv->BT_Service == BT_SCO) ? 0 : BIT2); + rtw_write8(adapt, 0x4fd, u1Tmp); + DBG_88E("BT write 0x%x = 0x%x for non-isolation\n", 0x4fd, u1Tmp); + rtw_write32(adapt, REG_BT_COEX_TABLE+4, 0xaaaa9aaa); + DBG_88E("BT write 0x%x = 0x%x\n", REG_BT_COEX_TABLE+4, 0xaaaa9aaa); - rtw_write32(padapter, REG_BT_COEX_TABLE+4, 0xaaaa9aaa); - DBG_88E("BT write 0x%x = 0x%x\n", REG_BT_COEX_TABLE+4, 0xaaaa9aaa); + rtw_write32(adapt, REG_BT_COEX_TABLE+8, 0xffbd0040); + DBG_88E("BT write 0x%x = 0x%x\n", REG_BT_COEX_TABLE+8, 0xffbd0040); - rtw_write32(padapter, REG_BT_COEX_TABLE+8, 0xffbd0040); - DBG_88E("BT write 0x%x = 0x%x\n", REG_BT_COEX_TABLE+8, 0xffbd0040); + rtw_write32(adapt, REG_BT_COEX_TABLE+0xc, 0x40000010); + DBG_88E("BT write 0x%x = 0x%x\n", REG_BT_COEX_TABLE+0xc, 0x40000010); - rtw_write32(padapter, REG_BT_COEX_TABLE+0xc, 0x40000010); - DBG_88E("BT write 0x%x = 0x%x\n", REG_BT_COEX_TABLE+0xc, 0x40000010); - - /* Config to 1T1R */ - u1Tmp = rtw_read8(padapter,rOFDM0_TRxPathEnable); - u1Tmp &= ~(BIT1); - rtw_write8( padapter, rOFDM0_TRxPathEnable, u1Tmp); - DBG_88E("BT write 0xC04 = 0x%x\n", u1Tmp); - - u1Tmp = rtw_read8(padapter, rOFDM1_TRxPathEnable); - u1Tmp &= ~(BIT1); - rtw_write8( padapter, rOFDM1_TRxPathEnable, u1Tmp); - DBG_88E("BT write 0xD04 = 0x%x\n", u1Tmp); + /* Config to 1T1R */ + u1Tmp = rtw_read8(adapt, rOFDM0_TRxPathEnable); + u1Tmp &= ~(BIT1); + rtw_write8(adapt, rOFDM0_TRxPathEnable, u1Tmp); + DBG_88E("BT write 0xC04 = 0x%x\n", u1Tmp); + u1Tmp = rtw_read8(adapt, rOFDM1_TRxPathEnable); + u1Tmp &= ~(BIT1); + rtw_write8(adapt, rOFDM1_TRxPathEnable, u1Tmp); + DBG_88E("BT write 0xD04 = 0x%x\n", u1Tmp); } } #endif -/* MAC init functions */ -static void -_SetMacID( - struct adapter * Adapter, u8* MacID - ) +/* MAC init functions */ +static void _SetMacID(struct adapter *Adapter, u8 *MacID) { u32 i; - for (i=0 ; i< MAC_ADDR_LEN ; i++) + for (i = 0; i < MAC_ADDR_LEN; i++) rtw_write32(Adapter, REG_MACID+i, MacID[i]); } -static void -_SetBSSID( - struct adapter * Adapter, u8* BSSID - ) +static void _SetBSSID(struct adapter *Adapter, u8 *BSSID) { u32 i; - for (i=0 ; i< MAC_ADDR_LEN ; i++) + for (i = 0; i < MAC_ADDR_LEN; i++) rtw_write32(Adapter, REG_BSSID+i, BSSID[i]); } - /* Shall USB interface init this? */ -static void -_InitInterrupt( - struct adapter * Adapter - ) +static void _InitInterrupt(struct adapter *Adapter) { - u32 imr,imr_ex; + u32 imr, imr_ex; u8 usb_opt; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); /* HISR write one to clear */ rtw_write32(Adapter, REG_HISR_88E, 0xFFFFFFFF); /* HIMR - */ - imr = IMR_PSTIMEOUT_88E | IMR_TBDER_88E | IMR_CPWM_88E | IMR_CPWM2_88E ; + imr = IMR_PSTIMEOUT_88E | IMR_TBDER_88E | IMR_CPWM_88E | IMR_CPWM2_88E; rtw_write32(Adapter, REG_HIMR_88E, imr); - pHalData->IntrMask[0]=imr; + haldata->IntrMask[0] = imr; - imr_ex = IMR_TXERR_88E | IMR_RXERR_88E | IMR_TXFOVW_88E |IMR_RXFOVW_88E; + imr_ex = IMR_TXERR_88E | IMR_RXERR_88E | IMR_TXFOVW_88E | IMR_RXFOVW_88E; rtw_write32(Adapter, REG_HIMRE_88E, imr_ex); - pHalData->IntrMask[1]=imr_ex; + haldata->IntrMask[1] = imr_ex; /* REG_USB_SPECIAL_OPTION - BIT(4) */ /* 0; Use interrupt endpoint to upload interrupt pkt */ /* 1; Use bulk endpoint to upload interrupt pkt, */ usb_opt = rtw_read8(Adapter, REG_USB_SPECIAL_OPTION); - if (!adapter_to_dvobj(Adapter)->ishighspeed) usb_opt = usb_opt & (~INT_BULK_SEL); else usb_opt = usb_opt | (INT_BULK_SEL); - rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, usb_opt ); + rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, usb_opt); } -static void -_InitQueueReservedPage( - struct adapter * Adapter - ) +static void _InitQueueReservedPage(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u32 outEPNum = (u32)pHalData->OutEpNumber; - u32 numHQ = 0; - u32 numLQ = 0; - u32 numNQ = 0; - u32 numPubQ; - u32 value32; - u8 value8; + u32 outEPNum = (u32)haldata->OutEpNumber; + u32 numHQ = 0; + u32 numLQ = 0; + u32 numNQ = 0; + u32 numPubQ; + u32 value32; + u8 value8; bool bWiFiConfig = pregistrypriv->wifi_spec; - if (bWiFiConfig) - { - if (pHalData->OutEpQueueSel & TX_SELE_HQ) - { + if (bWiFiConfig) { + if (haldata->OutEpQueueSel & TX_SELE_HQ) numHQ = 0x29; - } - if (pHalData->OutEpQueueSel & TX_SELE_LQ) - { + if (haldata->OutEpQueueSel & TX_SELE_LQ) numLQ = 0x1C; - } /* NOTE: This step shall be proceed before writting REG_RQPN. */ - if (pHalData->OutEpQueueSel & TX_SELE_NQ) { + if (haldata->OutEpQueueSel & TX_SELE_NQ) numNQ = 0x1C; - } value8 = (u8)_NPQ(numNQ); rtw_write8(Adapter, REG_RQPN_NPQ, value8); @@ -349,35 +297,31 @@ _InitQueueReservedPage( /* TX DMA */ value32 = _HPQ(numHQ) | _LPQ(numLQ) | _PUBQ(numPubQ) | LD_RQPN; rtw_write32(Adapter, REG_RQPN, value32); - } - else - { - rtw_write16(Adapter,REG_RQPN_NPQ, 0x0000);/* Just follow MP Team,??? Georgia 03/28 */ - rtw_write16(Adapter,REG_RQPN_NPQ, 0x0d); - rtw_write32(Adapter,REG_RQPN, 0x808E000d);/* reserve 7 page for LPS */ + } else { + rtw_write16(Adapter, REG_RQPN_NPQ, 0x0000);/* Just follow MP Team,??? Georgia 03/28 */ + rtw_write16(Adapter, REG_RQPN_NPQ, 0x0d); + rtw_write32(Adapter, REG_RQPN, 0x808E000d);/* reserve 7 page for LPS */ } } static void _InitTxBufferBoundary( - struct adapter * Adapter, + struct adapter *Adapter, u8 txpktbuf_bndy ) { struct registry_priv *pregistrypriv = &Adapter->registrypriv; - rtw_write8(Adapter, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy); rtw_write8(Adapter, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); rtw_write8(Adapter, REG_TXPKTBUF_WMAC_LBK_BF_HD, txpktbuf_bndy); rtw_write8(Adapter, REG_TRXFF_BNDY, txpktbuf_bndy); rtw_write8(Adapter, REG_TDECTRL+1, txpktbuf_bndy); - } static void _InitPageBoundary( - struct adapter * Adapter + struct adapter *Adapter ) { /* RX Page Boundary */ @@ -387,183 +331,135 @@ _InitPageBoundary( rtw_write16(Adapter, (REG_TRXFF_BNDY + 2), rxff_bndy); } - -static void -_InitNormalChipRegPriority( - struct adapter * Adapter, - u16 beQ, - u16 bkQ, - u16 viQ, - u16 voQ, - u16 mgtQ, - u16 hiQ +static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ, u16 bkQ, u16 viQ, u16 voQ, u16 mgtQ, u16 hiQ ) { u16 value16 = (rtw_read16(Adapter, REG_TRXDMA_CTRL) & 0x7); - value16 |= _TXDMA_BEQ_MAP(beQ) | _TXDMA_BKQ_MAP(bkQ) | - _TXDMA_VIQ_MAP(viQ) | _TXDMA_VOQ_MAP(voQ) | - _TXDMA_MGQ_MAP(mgtQ)| _TXDMA_HIQ_MAP(hiQ); + value16 |= _TXDMA_BEQ_MAP(beQ) | _TXDMA_BKQ_MAP(bkQ) | + _TXDMA_VIQ_MAP(viQ) | _TXDMA_VOQ_MAP(voQ) | + _TXDMA_MGQ_MAP(mgtQ) | _TXDMA_HIQ_MAP(hiQ); rtw_write16(Adapter, REG_TRXDMA_CTRL, value16); } -static void -_InitNormalChipOneOutEpPriority( - struct adapter * Adapter - ) +static void _InitNormalChipOneOutEpPriority(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); - u16 value = 0; - switch (pHalData->OutEpQueueSel) - { - case TX_SELE_HQ: - value = QUEUE_HIGH; - break; - case TX_SELE_LQ: - value = QUEUE_LOW; - break; - case TX_SELE_NQ: - value = QUEUE_NORMAL; - break; - default: - break; + u16 value = 0; + switch (haldata->OutEpQueueSel) { + case TX_SELE_HQ: + value = QUEUE_HIGH; + break; + case TX_SELE_LQ: + value = QUEUE_LOW; + break; + case TX_SELE_NQ: + value = QUEUE_NORMAL; + break; + default: + break; } - - _InitNormalChipRegPriority(Adapter, - value, - value, - value, - value, - value, - value - ); - + _InitNormalChipRegPriority(Adapter, value, value, value, value, + value, value); } -static void -_InitNormalChipTwoOutEpPriority( - struct adapter * Adapter - ) +static void _InitNormalChipTwoOutEpPriority(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u16 beQ,bkQ,viQ,voQ,mgtQ,hiQ; + u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; + u16 valueHi = 0; + u16 valueLow = 0; - - u16 valueHi = 0; - u16 valueLow = 0; - - switch (pHalData->OutEpQueueSel) - { - case (TX_SELE_HQ | TX_SELE_LQ): - valueHi = QUEUE_HIGH; - valueLow = QUEUE_LOW; - break; - case (TX_SELE_NQ | TX_SELE_LQ): - valueHi = QUEUE_NORMAL; - valueLow = QUEUE_LOW; - break; - case (TX_SELE_HQ | TX_SELE_NQ): - valueHi = QUEUE_HIGH; - valueLow = QUEUE_NORMAL; - break; - default: - break; + switch (haldata->OutEpQueueSel) { + case (TX_SELE_HQ | TX_SELE_LQ): + valueHi = QUEUE_HIGH; + valueLow = QUEUE_LOW; + break; + case (TX_SELE_NQ | TX_SELE_LQ): + valueHi = QUEUE_NORMAL; + valueLow = QUEUE_LOW; + break; + case (TX_SELE_HQ | TX_SELE_NQ): + valueHi = QUEUE_HIGH; + valueLow = QUEUE_NORMAL; + break; + default: + break; } - if (!pregistrypriv->wifi_spec ){ - beQ = valueLow; - bkQ = valueLow; - viQ = valueHi; - voQ = valueHi; + if (!pregistrypriv->wifi_spec) { + beQ = valueLow; + bkQ = valueLow; + viQ = valueHi; + voQ = valueHi; mgtQ = valueHi; - hiQ = valueHi; - } - else{/* for WMM ,CONFIG_OUT_EP_WIFI_MODE */ - beQ = valueLow; - bkQ = valueHi; - viQ = valueHi; - voQ = valueLow; + hiQ = valueHi; + } else {/* for WMM ,CONFIG_OUT_EP_WIFI_MODE */ + beQ = valueLow; + bkQ = valueHi; + viQ = valueHi; + voQ = valueLow; mgtQ = valueHi; - hiQ = valueHi; + hiQ = valueHi; } - - _InitNormalChipRegPriority(Adapter,beQ,bkQ,viQ,voQ,mgtQ,hiQ); - + _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); } -static void -_InitNormalChipThreeOutEpPriority( - struct adapter * Adapter - ) +static void _InitNormalChipThreeOutEpPriority(struct adapter *Adapter) { struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u16 beQ,bkQ,viQ,voQ,mgtQ,hiQ; + u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; - if (!pregistrypriv->wifi_spec ){/* typical setting */ - beQ = QUEUE_LOW; - bkQ = QUEUE_LOW; - viQ = QUEUE_NORMAL; - voQ = QUEUE_HIGH; + if (!pregistrypriv->wifi_spec) {/* typical setting */ + beQ = QUEUE_LOW; + bkQ = QUEUE_LOW; + viQ = QUEUE_NORMAL; + voQ = QUEUE_HIGH; mgtQ = QUEUE_HIGH; - hiQ = QUEUE_HIGH; - } - else{/* for WMM */ - beQ = QUEUE_LOW; - bkQ = QUEUE_NORMAL; - viQ = QUEUE_NORMAL; - voQ = QUEUE_HIGH; + hiQ = QUEUE_HIGH; + } else {/* for WMM */ + beQ = QUEUE_LOW; + bkQ = QUEUE_NORMAL; + viQ = QUEUE_NORMAL; + voQ = QUEUE_HIGH; mgtQ = QUEUE_HIGH; - hiQ = QUEUE_HIGH; + hiQ = QUEUE_HIGH; } - _InitNormalChipRegPriority(Adapter,beQ,bkQ,viQ,voQ,mgtQ,hiQ); + _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); } -static void -_InitQueuePriority( - struct adapter * Adapter - ) +static void _InitQueuePriority(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); - switch (pHalData->OutEpNumber) - { - case 1: - _InitNormalChipOneOutEpPriority(Adapter); - break; - case 2: - _InitNormalChipTwoOutEpPriority(Adapter); - break; - case 3: - _InitNormalChipThreeOutEpPriority(Adapter); - break; - default: - break; + switch (haldata->OutEpNumber) { + case 1: + _InitNormalChipOneOutEpPriority(Adapter); + break; + case 2: + _InitNormalChipTwoOutEpPriority(Adapter); + break; + case 3: + _InitNormalChipThreeOutEpPriority(Adapter); + break; + default: + break; } - - } - - -static void -_InitHardwareDropIncorrectBulkOut( - struct adapter * Adapter - ) +static void _InitHardwareDropIncorrectBulkOut(struct adapter *Adapter) { - u32 value32 = rtw_read32(Adapter, REG_TXDMA_OFFSET_CHK); + u32 value32 = rtw_read32(Adapter, REG_TXDMA_OFFSET_CHK); value32 |= DROP_DATA_EN; rtw_write32(Adapter, REG_TXDMA_OFFSET_CHK, value32); } -static void -_InitNetworkType( - struct adapter * Adapter - ) +static void _InitNetworkType(struct adapter *Adapter) { - u32 value32; + u32 value32; value32 = rtw_read32(Adapter, REG_CR); /* TODO: use the other function to set network type */ @@ -572,52 +468,41 @@ _InitNetworkType( rtw_write32(Adapter, REG_CR, value32); } -static void -_InitTransferPageSize( - struct adapter * Adapter - ) +static void _InitTransferPageSize(struct adapter *Adapter) { /* Tx page size is always 128. */ - u8 value8; + u8 value8; value8 = _PSRX(PBP_128) | _PSTX(PBP_128); rtw_write8(Adapter, REG_PBP, value8); } -static void -_InitDriverInfoSize( - struct adapter * Adapter, - u8 drvInfoSize - ) +static void _InitDriverInfoSize(struct adapter *Adapter, u8 drvInfoSize) { - rtw_write8(Adapter,REG_RX_DRVINFO_SZ, drvInfoSize); + rtw_write8(Adapter, REG_RX_DRVINFO_SZ, drvInfoSize); } -static void -_InitWMACSetting( - struct adapter * Adapter - ) +static void _InitWMACSetting(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); - pHalData->ReceiveConfig = - RCR_AAP | RCR_APM | RCR_AM | RCR_AB |RCR_CBSSID_DATA| RCR_CBSSID_BCN| RCR_APP_ICV | RCR_AMF | RCR_HTC_LOC_CTRL | RCR_APP_MIC | RCR_APP_PHYSTS; + haldata->ReceiveConfig = RCR_AAP | RCR_APM | RCR_AM | RCR_AB | + RCR_CBSSID_DATA | RCR_CBSSID_BCN | + RCR_APP_ICV | RCR_AMF | RCR_HTC_LOC_CTRL | + RCR_APP_MIC | RCR_APP_PHYSTS; /* some REG_RCR will be modified later by phy_ConfigMACWithHeaderFile() */ - rtw_write32(Adapter, REG_RCR, pHalData->ReceiveConfig); + rtw_write32(Adapter, REG_RCR, haldata->ReceiveConfig); /* Accept all multicast address */ rtw_write32(Adapter, REG_MAR, 0xFFFFFFFF); rtw_write32(Adapter, REG_MAR + 4, 0xFFFFFFFF); } -static void -_InitAdaptiveCtrl( - struct adapter * Adapter - ) +static void _InitAdaptiveCtrl(struct adapter *Adapter) { - u16 value16; - u32 value32; + u16 value16; + u32 value32; /* Response Rate Set */ value32 = rtw_read32(Adapter, REG_RRSR); @@ -634,37 +519,28 @@ _InitAdaptiveCtrl( /* Retry Limit */ value16 = _LRL(0x30) | _SRL(0x30); rtw_write16(Adapter, REG_RL, value16); - } -static void -_InitRateFallback( - struct adapter * Adapter - ) +static void _InitRateFallback(struct adapter *Adapter) { /* Set Data Auto Rate Fallback Retry Count register. */ rtw_write32(Adapter, REG_DARFRC, 0x00000000); rtw_write32(Adapter, REG_DARFRC+4, 0x10080404); rtw_write32(Adapter, REG_RARFRC, 0x04030201); rtw_write32(Adapter, REG_RARFRC+4, 0x08070605); - } - -static void -_InitEDCA( - struct adapter * Adapter - ) +static void _InitEDCA(struct adapter *Adapter) { /* Set Spec SIFS (used in NAV) */ - rtw_write16(Adapter,REG_SPEC_SIFS, 0x100a); - rtw_write16(Adapter,REG_MAC_SPEC_SIFS, 0x100a); + rtw_write16(Adapter, REG_SPEC_SIFS, 0x100a); + rtw_write16(Adapter, REG_MAC_SPEC_SIFS, 0x100a); /* Set SIFS for CCK */ - rtw_write16(Adapter,REG_SIFS_CTX, 0x100a); + rtw_write16(Adapter, REG_SIFS_CTX, 0x100a); /* Set SIFS for OFDM */ - rtw_write16(Adapter,REG_SIFS_TRX, 0x100a); + rtw_write16(Adapter, REG_SIFS_TRX, 0x100a); /* TXOP */ rtw_write32(Adapter, REG_EDCA_BE_PARAM, 0x005EA42B); @@ -673,45 +549,38 @@ _InitEDCA( rtw_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226); } -static void _InitBeaconMaxError(struct adapter * Adapter, bool InfraMode) +static void _InitBeaconMaxError(struct adapter *Adapter, bool InfraMode) { } -static void _InitHWLed(struct adapter * Adapter) +static void _InitHWLed(struct adapter *Adapter) { struct led_priv *pledpriv = &(Adapter->ledpriv); - if ( pledpriv->LedStrategy != HW_LED) + if (pledpriv->LedStrategy != HW_LED) return; /* HW led control */ /* to do .... */ /* must consider cases of antenna diversity/ commbo card/solo card/mini card */ - } -static void _InitRDGSetting(struct adapter * Adapter) +static void _InitRDGSetting(struct adapter *Adapter) { - rtw_write8(Adapter,REG_RD_CTRL,0xFF); + rtw_write8(Adapter, REG_RD_CTRL, 0xFF); rtw_write16(Adapter, REG_RD_NAV_NXT, 0x200); - rtw_write8(Adapter,REG_RD_RESP_PKT_TH,0x05); + rtw_write8(Adapter, REG_RD_RESP_PKT_TH, 0x05); } -static void -_InitRxSetting( - struct adapter * Adapter - ) +static void _InitRxSetting(struct adapter *Adapter) { rtw_write32(Adapter, REG_MACID, 0x87654321); rtw_write32(Adapter, 0x0700, 0x87654321); } -static void -_InitRetryFunction( - struct adapter * Adapter - ) +static void _InitRetryFunction(struct adapter *Adapter) { - u8 value8; + u8 value8; value8 = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL); value8 |= EN_AMPDU_RTY_NEW; @@ -736,27 +605,23 @@ _InitRetryFunction( * 12/10/2010 MHC Seperate to smaller function. * *---------------------------------------------------------------------------*/ -static void -usb_AggSettingTxUpdate( - struct adapter * Adapter - ) +static void usb_AggSettingTxUpdate(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u32 value32; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u32 value32; if (Adapter->registrypriv.wifi_spec) - pHalData->UsbTxAggMode = false; + haldata->UsbTxAggMode = false; - if (pHalData->UsbTxAggMode){ + if (haldata->UsbTxAggMode) { value32 = rtw_read32(Adapter, REG_TDECTRL); value32 = value32 & ~(BLK_DESC_NUM_MASK << BLK_DESC_NUM_SHIFT); - value32 |= ((pHalData->UsbTxAggDescNum & BLK_DESC_NUM_MASK) << BLK_DESC_NUM_SHIFT); + value32 |= ((haldata->UsbTxAggDescNum & BLK_DESC_NUM_MASK) << BLK_DESC_NUM_SHIFT); rtw_write32(Adapter, REG_TDECTRL, value32); } } /* usb_AggSettingTxUpdate */ - /*----------------------------------------------------------------------------- * Function: usb_AggSettingRxUpdate() * @@ -774,92 +639,84 @@ usb_AggSettingTxUpdate( *---------------------------------------------------------------------------*/ static void usb_AggSettingRxUpdate( - struct adapter * Adapter + struct adapter *Adapter ) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 valueDMA; - u8 valueUSB; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u8 valueDMA; + u8 valueUSB; valueDMA = rtw_read8(Adapter, REG_TRXDMA_CTRL); valueUSB = rtw_read8(Adapter, REG_USB_SPECIAL_OPTION); - switch (pHalData->UsbRxAggMode) - { - case USB_RX_AGG_DMA: - valueDMA |= RXDMA_AGG_EN; - valueUSB &= ~USB_AGG_EN; - break; - case USB_RX_AGG_USB: - valueDMA &= ~RXDMA_AGG_EN; - valueUSB |= USB_AGG_EN; - break; - case USB_RX_AGG_MIX: - valueDMA |= RXDMA_AGG_EN; - valueUSB |= USB_AGG_EN; - break; - case USB_RX_AGG_DISABLE: - default: - valueDMA &= ~RXDMA_AGG_EN; - valueUSB &= ~USB_AGG_EN; - break; + switch (haldata->UsbRxAggMode) { + case USB_RX_AGG_DMA: + valueDMA |= RXDMA_AGG_EN; + valueUSB &= ~USB_AGG_EN; + break; + case USB_RX_AGG_USB: + valueDMA &= ~RXDMA_AGG_EN; + valueUSB |= USB_AGG_EN; + break; + case USB_RX_AGG_MIX: + valueDMA |= RXDMA_AGG_EN; + valueUSB |= USB_AGG_EN; + break; + case USB_RX_AGG_DISABLE: + default: + valueDMA &= ~RXDMA_AGG_EN; + valueUSB &= ~USB_AGG_EN; + break; } rtw_write8(Adapter, REG_TRXDMA_CTRL, valueDMA); rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, valueUSB); - switch (pHalData->UsbRxAggMode) - { - case USB_RX_AGG_DMA: - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, pHalData->UsbRxAggPageCount); - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, pHalData->UsbRxAggPageTimeout); - break; - case USB_RX_AGG_USB: - rtw_write8(Adapter, REG_USB_AGG_TH, pHalData->UsbRxAggBlockCount); - rtw_write8(Adapter, REG_USB_AGG_TO, pHalData->UsbRxAggBlockTimeout); - break; - case USB_RX_AGG_MIX: - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, pHalData->UsbRxAggPageCount); - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, (pHalData->UsbRxAggPageTimeout& 0x1F));/* 0x280[12:8] */ - - rtw_write8(Adapter, REG_USB_AGG_TH, pHalData->UsbRxAggBlockCount); - rtw_write8(Adapter, REG_USB_AGG_TO, pHalData->UsbRxAggBlockTimeout); - - break; - case USB_RX_AGG_DISABLE: - default: - /* TODO: */ - break; + switch (haldata->UsbRxAggMode) { + case USB_RX_AGG_DMA: + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, haldata->UsbRxAggPageTimeout); + break; + case USB_RX_AGG_USB: + rtw_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); + rtw_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); + break; + case USB_RX_AGG_MIX: + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, (haldata->UsbRxAggPageTimeout & 0x1F));/* 0x280[12:8] */ + rtw_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); + rtw_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); + break; + case USB_RX_AGG_DISABLE: + default: + /* TODO: */ + break; } - switch (PBP_128) - { - case PBP_128: - pHalData->HwRxPageSize = 128; - break; - case PBP_64: - pHalData->HwRxPageSize = 64; - break; - case PBP_256: - pHalData->HwRxPageSize = 256; - break; - case PBP_512: - pHalData->HwRxPageSize = 512; - break; - case PBP_1024: - pHalData->HwRxPageSize = 1024; - break; - default: - break; + switch (PBP_128) { + case PBP_128: + haldata->HwRxPageSize = 128; + break; + case PBP_64: + haldata->HwRxPageSize = 64; + break; + case PBP_256: + haldata->HwRxPageSize = 256; + break; + case PBP_512: + haldata->HwRxPageSize = 512; + break; + case PBP_1024: + haldata->HwRxPageSize = 1024; + break; + default: + break; } } /* usb_AggSettingRxUpdate */ -static void -InitUsbAggregationSetting( - struct adapter * Adapter - ) +static void InitUsbAggregationSetting(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); /* Tx aggregation setting */ usb_AggSettingTxUpdate(Adapter); @@ -868,11 +725,11 @@ InitUsbAggregationSetting( usb_AggSettingRxUpdate(Adapter); /* 201/12/10 MH Add for USB agg mode dynamic switch. */ - pHalData->UsbRxHighSpeedMode = false; + haldata->UsbRxHighSpeedMode = false; } static void HalRxAggr8188EUsb( - struct adapter * Adapter, + struct adapter *Adapter, bool Value ) { @@ -897,32 +754,22 @@ HalRxAggr8188EUsb( * 12/10/2010 MHC Create Version 0. * *---------------------------------------------------------------------------*/ -static void -USB_AggModeSwitch( - struct adapter * Adapter - ) +static void USB_AggModeSwitch(struct adapter *Adapter) { } /* USB_AggModeSwitch */ -static void -_InitOperationMode( - struct adapter * Adapter - ) +static void _InitOperationMode(struct adapter *Adapter) { } - - static void -_InitBeaconParameters( - struct adapter * Adapter - ) +static void _InitBeaconParameters(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); rtw_write16(Adapter, REG_BCN_CTRL, 0x1010); /* TODO: Remove these magic number */ - rtw_write16(Adapter, REG_TBTT_PROHIBIT,0x6404);/* ms */ + rtw_write16(Adapter, REG_TBTT_PROHIBIT, 0x6404);/* ms */ rtw_write8(Adapter, REG_DRVERLYINT, DRIVER_EARLY_INT_TIME);/* 5ms */ rtw_write8(Adapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME); /* 2ms */ @@ -930,40 +777,35 @@ _InitBeaconParameters( /* beacause test chip does not contension before sending beacon. by tynli. 2009.11.03 */ rtw_write16(Adapter, REG_BCNTCFG, 0x660F); - pHalData->RegBcnCtrlVal = rtw_read8(Adapter, REG_BCN_CTRL); - pHalData->RegTxPause = rtw_read8(Adapter, REG_TXPAUSE); - pHalData->RegFwHwTxQCtrl = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL+2); - pHalData->RegReg542 = rtw_read8(Adapter, REG_TBTT_PROHIBIT+2); - pHalData->RegCR_1 = rtw_read8(Adapter, REG_CR+1); + haldata->RegBcnCtrlVal = rtw_read8(Adapter, REG_BCN_CTRL); + haldata->RegTxPause = rtw_read8(Adapter, REG_TXPAUSE); + haldata->RegFwHwTxQCtrl = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL+2); + haldata->RegReg542 = rtw_read8(Adapter, REG_TBTT_PROHIBIT+2); + haldata->RegCR_1 = rtw_read8(Adapter, REG_CR+1); } -static void -_InitRFType( - struct adapter * Adapter - ) +static void _InitRFType(struct adapter *Adapter) { struct registry_priv *pregpriv = &Adapter->registrypriv; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - bool is92CU = IS_92C_SERIAL(pHalData->VersionID); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + bool is92CU = IS_92C_SERIAL(haldata->VersionID); - pHalData->rf_chip = RF_6052; + haldata->rf_chip = RF_6052; - if (false == is92CU){ - pHalData->rf_type = RF_1T1R; + if (false == is92CU) { + haldata->rf_type = RF_1T1R; DBG_88E("Set RF Chip ID to RF_6052 and RF type to 1T1R.\n"); return; } /* TODO: Consider that EEPROM set 92CU to 1T1R later. */ /* Force to overwrite setting according to chip version. Ignore EEPROM setting. */ - MSG_88E("Set RF Chip ID to RF_6052 and RF type to %d.\n", pHalData->rf_type); - + MSG_88E("Set RF Chip ID to RF_6052 and RF type to %d.\n", haldata->rf_type); } - static void _BeaconFunctionEnable( - struct adapter * Adapter, + struct adapter *Adapter, bool Enable, bool Linked ) @@ -973,10 +815,9 @@ _BeaconFunctionEnable( rtw_write8(Adapter, REG_RD_CTRL+1, 0x6F); } - /* Set CCK and OFDM Block "ON" */ static void _BBTurnOnBlock( - struct adapter * Adapter + struct adapter *Adapter ) { PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bCCKEn, 0x1); @@ -984,7 +825,7 @@ static void _BBTurnOnBlock( } static void _RfPowerSave( - struct adapter * Adapter + struct adapter *Adapter ) { } @@ -995,25 +836,23 @@ enum { }; static void -_InitAntenna_Selection( struct adapter * Adapter) +_InitAntenna_Selection(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); - if (pHalData->AntDivCfg==0) + if (haldata->AntDivCfg == 0) return; - DBG_88E("==> %s ....\n",__func__); + DBG_88E("==> %s ....\n", __func__); rtw_write32(Adapter, REG_LEDCFG0, rtw_read32(Adapter, REG_LEDCFG0)|BIT23); PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, BIT13, 0x01); if (PHY_QueryBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300) == Antenna_A) - pHalData->CurAntenna = Antenna_A; + haldata->CurAntenna = Antenna_A; else - pHalData->CurAntenna = Antenna_B; - DBG_88E("%s,Cur_ant:(%x)%s\n",__func__,pHalData->CurAntenna,(pHalData->CurAntenna == Antenna_A)?"Antenna_A":"Antenna_B"); - - + haldata->CurAntenna = Antenna_B; + DBG_88E("%s,Cur_ant:(%x)%s\n", __func__, haldata->CurAntenna, (haldata->CurAntenna == Antenna_A) ? "Antenna_A" : "Antenna_B"); } /* */ @@ -1023,7 +862,7 @@ _InitAntenna_Selection( struct adapter * Adapter) /* */ static void HalDetectSelectiveSuspendMode( - struct adapter * Adapter + struct adapter *Adapter ) { } /* HalDetectSelectiveSuspendMode */ @@ -1042,54 +881,40 @@ HalDetectSelectiveSuspendMode( * When Who Remark * 08/23/2010 MHC HW suspend mode switch test.. *---------------------------------------------------------------------------*/ -static void -HwSuspendModeEnable_88eu( - struct adapter * pAdapter, - u8 Type - ) +enum rt_rf_power_state RfOnOffDetect(struct adapter *adapt) { -} /* HwSuspendModeEnable92Cu */ - -enum rt_rf_power_state RfOnOffDetect(struct adapter * pAdapter) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - u8 val8; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + u8 val8; enum rt_rf_power_state rfpowerstate = rf_off; - if (pAdapter->pwrctrlpriv.bHWPowerdown) - { - val8 = rtw_read8(pAdapter, REG_HSISR); + if (adapt->pwrctrlpriv.bHWPowerdown) { + val8 = rtw_read8(adapt, REG_HSISR); DBG_88E("pwrdown, 0x5c(BIT7)=%02x\n", val8); - rfpowerstate = (val8 & BIT7) ? rf_off: rf_on; - } - else /* rf on/off */ - { - rtw_write8( pAdapter, REG_MAC_PINMUX_CFG,rtw_read8(pAdapter, REG_MAC_PINMUX_CFG)&~(BIT3)); - val8 = rtw_read8(pAdapter, REG_GPIO_IO_SEL); + rfpowerstate = (val8 & BIT7) ? rf_off : rf_on; + } else { /* rf on/off */ + rtw_write8(adapt, REG_MAC_PINMUX_CFG, rtw_read8(adapt, REG_MAC_PINMUX_CFG)&~(BIT3)); + val8 = rtw_read8(adapt, REG_GPIO_IO_SEL); DBG_88E("GPIO_IN=%02x\n", val8); rfpowerstate = (val8 & BIT3) ? rf_on : rf_off; } return rfpowerstate; } /* HalDetectPwrDownMode */ -void _ps_open_RF(struct adapter *padapter); - -static u32 rtl8188eu_hal_init(struct adapter * Adapter) +static u32 rtl8188eu_hal_init(struct adapter *Adapter) { - u8 value8 = 0; + u8 value8 = 0; u16 value16; - u8 txpktbuf_bndy; - u32 status = _SUCCESS; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 txpktbuf_bndy; + u32 status = _SUCCESS; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; struct registry_priv *pregistrypriv = &Adapter->registrypriv; enum rt_rf_power_state eRfPowerStateToSet; #ifdef CONFIG_BT_COEXIST - struct btcoexist_priv *pbtpriv = &(pHalData->bt_coexist); + struct btcoexist_priv *pbtpriv = &(haldata->bt_coexist); #endif u32 init_start_time = rtw_get_current_time(); - #define HAL_INIT_PROFILE_TAG(stage) do {} while (0) _func_enter_; @@ -1100,11 +925,11 @@ _func_enter_; Adapter->pwrctrlpriv.wowlan_wake_reason = rtw_read8(Adapter, REG_WOWLAN_WAKE_REASON); DBG_88E("%s wowlan_wake_reason: 0x%02x\n", - __func__, Adapter->pwrctrlpriv.wowlan_wake_reason); + __func__, Adapter->pwrctrlpriv.wowlan_wake_reason); - if (rtw_read8(Adapter, REG_MCUFWDL)&BIT7){ /*&& + if (rtw_read8(Adapter, REG_MCUFWDL)&BIT7) { /*&& (Adapter->pwrctrlpriv.wowlan_wake_reason & FWDecisionDisconnect)) {*/ - u8 reg_val=0; + u8 reg_val = 0; DBG_88E("+Reset Entry+\n"); rtw_write8(Adapter, REG_MCUFWDL, 0x00); _8051Reset88E(Adapter); @@ -1127,20 +952,17 @@ _func_enter_; } #endif /* CONFIG_WOWLAN */ - if (Adapter->pwrctrlpriv.bkeepfwalive) - { + if (Adapter->pwrctrlpriv.bkeepfwalive) { _ps_open_RF(Adapter); - if (pHalData->odmpriv.RFCalibrateInfo.bIQKInitialized){ - PHY_IQCalibrate_8188E(Adapter,true); - } - else - { - PHY_IQCalibrate_8188E(Adapter,false); - pHalData->odmpriv.RFCalibrateInfo.bIQKInitialized = true; + if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { + PHY_IQCalibrate_8188E(Adapter, true); + } else { + PHY_IQCalibrate_8188E(Adapter, false); + haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; } - ODM_TXPowerTrackingCheck(&pHalData->odmpriv ); + ODM_TXPowerTrackingCheck(&haldata->odmpriv); PHY_LCCalibrate_8188E(Adapter); goto exit; @@ -1148,16 +970,15 @@ _func_enter_; HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_PW_ON); status = rtl8188eu_InitPowerOn(Adapter); - if (status == _FAIL){ + if (status == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("Failed to init power on!\n")); goto exit; } /* Save target channel */ - pHalData->CurrentChannel = 6;/* default set to 6 */ + haldata->CurrentChannel = 6;/* default set to 6 */ - - if (pwrctrlpriv->reg_rfoff == true){ + if (pwrctrlpriv->reg_rfoff) { pwrctrlpriv->rf_pwrstate = rf_off; } @@ -1181,16 +1002,13 @@ _func_enter_; _InitTxBufferBoundary(Adapter, 0); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_DOWNLOAD_FW); - if (Adapter->registrypriv.mp_mode == 1) - { + if (Adapter->registrypriv.mp_mode == 1) { _InitRxSetting(Adapter); Adapter->bFWReady = false; - pHalData->fw_ractrl = false; - } - else - { + haldata->fw_ractrl = false; + } else { #ifdef CONFIG_WOWLAN - status = rtl8188e_FirmwareDownload(Adapter, false); + status = rtl8188e_FirmwareDownload(Adapter, false); #else status = rtl8188e_FirmwareDownload(Adapter); #endif /* CONFIG_WOWLAN */ @@ -1198,12 +1016,12 @@ _func_enter_; if (status != _SUCCESS) { DBG_88E("%s: Download Firmware failed!!\n", __func__); Adapter->bFWReady = false; - pHalData->fw_ractrl = false; + haldata->fw_ractrl = false; return status; } else { - RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Initializepadapter8192CSdio(): Download Firmware Success!!\n")); + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Initializeadapt8192CSdio(): Download Firmware Success!!\n")); Adapter->bFWReady = true; - pHalData->fw_ractrl = false; + haldata->fw_ractrl = false; } } rtl8188e_InitializeFirmwareVars(Adapter); @@ -1211,8 +1029,7 @@ _func_enter_; HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MAC); #if (HAL_MAC_ENABLE == 1) status = PHY_MACConfig8188E(Adapter); - if (status == _FAIL) - { + if (status == _FAIL) { DBG_88E(" ### Failed to init MAC ......\n "); goto exit; } @@ -1224,19 +1041,16 @@ _func_enter_; HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BB); #if (HAL_BB_ENABLE == 1) status = PHY_BBConfig8188E(Adapter); - if (status == _FAIL) - { + if (status == _FAIL) { DBG_88E(" ### Failed to init BB ......\n "); goto exit; } #endif - HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_RF); #if (HAL_RF_ENABLE == 1) status = PHY_RFConfig8188E(Adapter); - if (status == _FAIL) - { + if (status == _FAIL) { DBG_88E(" ### Failed to init RF ......\n "); goto exit; } @@ -1244,8 +1058,8 @@ _func_enter_; HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_EFUSE_PATCH); status = rtl8188e_iol_efuse_patch(Adapter); - if (status == _FAIL){ - DBG_88E("%s rtl8188e_iol_efuse_patch failed\n",__func__); + if (status == _FAIL) { + DBG_88E("%s rtl8188e_iol_efuse_patch failed\n", __func__); goto exit; } @@ -1253,7 +1067,7 @@ _func_enter_; HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_LLTT); status = InitLLTTable(Adapter, txpktbuf_bndy); - if (status == _FAIL){ + if (status == _FAIL) { RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("Failed to init LLT table\n")); goto exit; } @@ -1283,9 +1097,8 @@ _func_enter_; value16 |= (MACTXEN | MACRXEN); rtw_write8(Adapter, REG_CR, value16); - if (pHalData->bRDGEnable){ + if (haldata->bRDGEnable) _InitRDGSetting(Adapter); - } /* Enable TX Report */ /* Enable Tx Report Timer */ @@ -1304,8 +1117,8 @@ _func_enter_; _InitHWLed(Adapter); /* Keep RfRegChnlVal for later use. */ - pHalData->RfRegChnlVal[0] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)0, RF_CHNLBW, bRFRegOffsetMask); - pHalData->RfRegChnlVal[1] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)1, RF_CHNLBW, bRFRegOffsetMask); + haldata->RfRegChnlVal[0] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)0, RF_CHNLBW, bRFRegOffsetMask); + haldata->RfRegChnlVal[1] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)1, RF_CHNLBW, bRFRegOffsetMask); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_TURN_ON_BLOCK); _BBTurnOnBlock(Adapter); @@ -1315,7 +1128,7 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_SECURITY); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); /* 2010/12/17 MH We need to set TX power according to EFUSE content at first. */ - PHY_SetTxPowerLevel8188E(Adapter, pHalData->CurrentChannel); + PHY_SetTxPowerLevel8188E(Adapter, haldata->CurrentChannel); /* Move by Neo for USB SS to below setp */ /* _RfPowerSave(Adapter); */ @@ -1330,10 +1143,10 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); /* HW SEQ CTRL */ /* set 0x0 to 0xFF by tynli. Default enable HW SEQ NUM. */ - rtw_write8(Adapter,REG_HWSEQ_CTRL, 0xFF); + rtw_write8(Adapter, REG_HWSEQ_CTRL, 0xFF); if (pregistrypriv->wifi_spec) - rtw_write16(Adapter,REG_FAST_EDCA_CTRL ,0); + rtw_write16(Adapter, REG_FAST_EDCA_CTRL, 0); /* Nav limit , suggest by scott */ rtw_write8(Adapter, 0x652, 0x0); @@ -1341,61 +1154,52 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_HAL_DM); rtl8188e_InitHalDm(Adapter); - if (Adapter->registrypriv.mp_mode == 1) - { - Adapter->mppriv.channel = pHalData->CurrentChannel; + if (Adapter->registrypriv.mp_mode == 1) { + Adapter->mppriv.channel = haldata->CurrentChannel; MPT_InitializeAdapter(Adapter, Adapter->mppriv.channel); - } - else - { - /* */ - /* 2010/08/11 MH Merge from 8192SE for Minicard init. We need to confirm current radio status */ - /* and then decide to enable RF or not.!!!??? For Selective suspend mode. We may not */ - /* call initstruct adapter. May cause some problem?? */ - /* */ - /* Fix the bug that Hw/Sw radio off before S3/S4, the RF off action will not be executed */ - /* in MgntActSet_RF_State() after wake up, because the value of pHalData->eRFPowerState */ - /* is the same as eRfOff, we should change it to eRfOn after we config RF parameters. */ - /* Added by tynli. 2010.03.30. */ - pwrctrlpriv->rf_pwrstate = rf_on; + } else { + /* 2010/08/11 MH Merge from 8192SE for Minicard init. We need to confirm current radio status */ + /* and then decide to enable RF or not.!!!??? For Selective suspend mode. We may not */ + /* call initstruct adapter. May cause some problem?? */ + /* Fix the bug that Hw/Sw radio off before S3/S4, the RF off action will not be executed */ + /* in MgntActSet_RF_State() after wake up, because the value of haldata->eRFPowerState */ + /* is the same as eRfOff, we should change it to eRfOn after we config RF parameters. */ + /* Added by tynli. 2010.03.30. */ + pwrctrlpriv->rf_pwrstate = rf_on; - /* enable Tx report. */ - rtw_write8(Adapter, REG_FWHW_TXQ_CTRL+1, 0x0F); + /* enable Tx report. */ + rtw_write8(Adapter, REG_FWHW_TXQ_CTRL+1, 0x0F); - /* Suggested by SD1 pisa. Added by tynli. 2011.10.21. */ - rtw_write8(Adapter, REG_EARLY_MODE_CONTROL+3, 0x01);/* Pretx_en, for WEP/TKIP SEC */ + /* Suggested by SD1 pisa. Added by tynli. 2011.10.21. */ + rtw_write8(Adapter, REG_EARLY_MODE_CONTROL+3, 0x01);/* Pretx_en, for WEP/TKIP SEC */ - /* tynli_test_tx_report. */ - rtw_write16(Adapter, REG_TX_RPT_TIME, 0x3DF0); + /* tynli_test_tx_report. */ + rtw_write16(Adapter, REG_TX_RPT_TIME, 0x3DF0); - /* enable tx DMA to drop the redundate data of packet */ - rtw_write16(Adapter,REG_TXDMA_OFFSET_CHK, (rtw_read16(Adapter,REG_TXDMA_OFFSET_CHK) | DROP_DATA_EN)); + /* enable tx DMA to drop the redundate data of packet */ + rtw_write16(Adapter, REG_TXDMA_OFFSET_CHK, (rtw_read16(Adapter, REG_TXDMA_OFFSET_CHK) | DROP_DATA_EN)); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_IQK); - /* 2010/08/26 MH Merge from 8192CE. */ - if (pwrctrlpriv->rf_pwrstate == rf_on) - { - if (pHalData->odmpriv.RFCalibrateInfo.bIQKInitialized){ - PHY_IQCalibrate_8188E(Adapter,true); - } - else - { - PHY_IQCalibrate_8188E(Adapter,false); - pHalData->odmpriv.RFCalibrateInfo.bIQKInitialized = true; - } + /* 2010/08/26 MH Merge from 8192CE. */ + if (pwrctrlpriv->rf_pwrstate == rf_on) { + if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { + PHY_IQCalibrate_8188E(Adapter, true); + } else { + PHY_IQCalibrate_8188E(Adapter, false); + haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; + } HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_PW_TRACK); - ODM_TXPowerTrackingCheck(&pHalData->odmpriv ); - + ODM_TXPowerTrackingCheck(&haldata->odmpriv); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_LCK); - PHY_LCCalibrate_8188E(Adapter); + PHY_LCCalibrate_8188E(Adapter); + } } -} /* HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_PABIAS); */ -/* _InitPABias(Adapter); */ +/* _InitPABias(Adapter); */ rtw_write8(Adapter, REG_USB_HRPWM, 0); /* ack for xmit mgmt frames. */ @@ -1411,22 +1215,24 @@ _func_exit_; return status; } -void _ps_open_RF(struct adapter *padapter) { - /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ - /* phy_SsPwrSwitch92CU(padapter, rf_on, 1); */ -} - -static void _ps_close_RF(struct adapter *padapter){ - /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ - /* phy_SsPwrSwitch92CU(padapter, rf_off, 1); */ -} - -static void CardDisableRTL8188EU(struct adapter * Adapter) +void _ps_open_RF(struct adapter *adapt) { - u8 val8; - u16 val16; - u32 val32; - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ + /* phy_SsPwrSwitch92CU(adapt, rf_on, 1); */ +} + +static void _ps_close_RF(struct adapter *adapt) +{ + /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ + /* phy_SsPwrSwitch92CU(adapt, rf_off, 1); */ +} + +static void CardDisableRTL8188EU(struct adapter *Adapter) +{ + u8 val8; + u16 val16; + u32 val32; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("CardDisableRTL8188EU\n")); @@ -1440,12 +1246,10 @@ static void CardDisableRTL8188EU(struct adapter * Adapter) /* Run LPS WL RFOFF flow */ HalPwrSeqCmdParsing(Adapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_LPS_ENTER_FLOW); - /* 2. 0x1F[7:0] = 0 turn off RF */ val8 = rtw_read8(Adapter, REG_MCUFWDL); - if ((val8 & RAM_DL_SEL) && Adapter->bFWReady) /* 8051 RAM code */ - { + if ((val8 & RAM_DL_SEL) && Adapter->bFWReady) { /* 8051 RAM code */ /* Reset MCU 0x2[10]=0. */ val8 = rtw_read8(Adapter, REG_SYS_FUNC_EN+1); val8 &= ~BIT(2); /* 0x2[10], FEN_CPUEN */ @@ -1479,54 +1283,51 @@ static void CardDisableRTL8188EU(struct adapter * Adapter) val8 = rtw_read8(Adapter, REG_GPIO_IO_SEL+1); rtw_write8(Adapter, REG_GPIO_IO_SEL+1, val8|0x0F);/* Reg0x43 */ rtw_write32(Adapter, REG_BB_PAD_CTRL, 0x00080808);/* set LNA ,TRSW,EX_PA Pin to output mode */ - pHalData->bMacPwrCtrlOn = false; + haldata->bMacPwrCtrlOn = false; Adapter->bFWReady = false; } -static void rtl8192cu_hw_power_down(struct adapter *padapter) +static void rtl8192cu_hw_power_down(struct adapter *adapt) { /* 2010/-8/09 MH For power down module, we need to enable register block contrl reg at 0x1c. */ /* Then enable power down control bit of register 0x04 BIT4 and BIT15 as 1. */ /* Enable register area 0x0-0xc. */ - rtw_write8(padapter,REG_RSV_CTRL, 0x0); - rtw_write16(padapter, REG_APS_FSMCO, 0x8812); + rtw_write8(adapt, REG_RSV_CTRL, 0x0); + rtw_write16(adapt, REG_APS_FSMCO, 0x8812); } -static u32 rtl8188eu_hal_deinit(struct adapter * Adapter) +static u32 rtl8188eu_hal_deinit(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - DBG_88E("==> %s\n",__func__); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + DBG_88E("==> %s\n", __func__); rtw_write32(Adapter, REG_HIMR_88E, IMR_DISABLED_88E); rtw_write32(Adapter, REG_HIMRE_88E, IMR_DISABLED_88E); - DBG_88E("bkeepfwalive(%x)\n",Adapter->pwrctrlpriv.bkeepfwalive); - if (Adapter->pwrctrlpriv.bkeepfwalive) - { + DBG_88E("bkeepfwalive(%x)\n", Adapter->pwrctrlpriv.bkeepfwalive); + if (Adapter->pwrctrlpriv.bkeepfwalive) { _ps_close_RF(Adapter); if ((Adapter->pwrctrlpriv.bHWPwrPindetect) && (Adapter->pwrctrlpriv.bHWPowerdown)) rtl8192cu_hw_power_down(Adapter); } else { - if (Adapter->hw_init_completed == true){ + if (Adapter->hw_init_completed) { CardDisableRTL8188EU(Adapter); - if ((Adapter->pwrctrlpriv.bHWPwrPindetect ) && (Adapter->pwrctrlpriv.bHWPowerdown)) + if ((Adapter->pwrctrlpriv.bHWPwrPindetect) && (Adapter->pwrctrlpriv.bHWPowerdown)) rtl8192cu_hw_power_down(Adapter); - } } return _SUCCESS; } - -static unsigned int rtl8188eu_inirp_init(struct adapter * Adapter) +static unsigned int rtl8188eu_inirp_init(struct adapter *Adapter) { u8 i; struct recv_buf *precvbuf; uint status; - struct dvobj_priv *pdev= adapter_to_dvobj(Adapter); - struct intf_hdl * pintfhdl=&Adapter->iopriv.intf; + struct dvobj_priv *pdev = adapter_to_dvobj(Adapter); + struct intf_hdl *pintfhdl = &Adapter->iopriv.intf; struct recv_priv *precvpriv = &(Adapter->recvpriv); u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); @@ -1544,8 +1345,8 @@ _func_enter_; /* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - if (_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf) == false ) { - RT_TRACE(_module_hci_hal_init_c_,_drv_err_,("usb_rx_init: usb_read_port error\n")); + if (_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf) == false) { + RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); status = _FAIL; goto exit; } @@ -1556,257 +1357,161 @@ _func_enter_; exit: - RT_TRACE(_module_hci_hal_init_c_,_drv_info_,("<=== usb_inirp_init\n")); + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<=== usb_inirp_init\n")); _func_exit_; return status; } -static unsigned int rtl8188eu_inirp_deinit(struct adapter * Adapter) +static unsigned int rtl8188eu_inirp_deinit(struct adapter *Adapter) { - RT_TRACE(_module_hci_hal_init_c_,_drv_info_,("\n ===> usb_rx_deinit\n")); + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n ===> usb_rx_deinit\n")); rtw_read_port_cancel(Adapter); - RT_TRACE(_module_hci_hal_init_c_,_drv_info_,("\n <=== usb_rx_deinit\n")); + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n <=== usb_rx_deinit\n")); return _SUCCESS; } /* */ /* */ -/* EEPROM/EFUSE Content Parsing */ +/* EEPROM/EFUSE Content Parsing */ /* */ /* */ -static void _ReadIDs(struct adapter * Adapter, u8 *PROMContent, bool AutoloadFail) -{ -} - -static void -_ReadBoardType( - struct adapter * Adapter, - u8* PROMContent, - bool AutoloadFail - ) -{ - -} - - -static void -_ReadLEDSetting( - struct adapter * Adapter, - u8* PROMContent, - bool AutoloadFail - ) +static void _ReadLEDSetting(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail) { struct led_priv *pledpriv = &(Adapter->ledpriv); - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + pledpriv->bRegUseLed = true; - - switch (pHalData->CustomerID) - { - default: - pledpriv->LedStrategy = SW_LED_MODE1; - break; - } - pHalData->bLedOpenDrain = true;/* Support Open-drain arrangement for controlling the LED. Added by Roger, 2009.10.16. */ + pledpriv->LedStrategy = SW_LED_MODE1; + haldata->bLedOpenDrain = true;/* Support Open-drain arrangement for controlling the LED. */ } -static void -_ReadThermalMeter( - struct adapter * Adapter, - u8* PROMContent, - bool AutoloadFail - ) +static void readAntennaDiversity(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) { + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct registry_priv *registry_par = &adapt->registrypriv; + + haldata->AntDivCfg = registry_par->antdiv_cfg; /* 0:OFF , 1:ON, */ } -static void -_ReadRFSetting( - struct adapter * Adapter, - u8* PROMContent, - bool AutoloadFail - ) +static void Hal_EfuseParsePIDVID_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) { -} + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); -static void -_ReadPROMVersion( - struct adapter * Adapter, - u8* PROMContent, - bool AutoloadFail - ) -{ -} - -static void -readAntennaDiversity( - struct adapter * pAdapter, - u8 *hwinfo, - bool AutoLoadFail - ) -{ - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - struct registry_priv *registry_par = &pAdapter->registrypriv; - - pHalData->AntDivCfg = registry_par->antdiv_cfg ; /* 0:OFF , 1:ON, */ -} - -static void -hal_InitPGData( - struct adapter * pAdapter, - u8 *PROMContent - ) -{ -} -static void -Hal_EfuseParsePIDVID_8188EU( - struct adapter * pAdapter, - u8* hwinfo, - bool AutoLoadFail - ) -{ - - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - - if ( !AutoLoadFail ) - { + if (!AutoLoadFail) { /* VID, PID */ - pHalData->EEPROMVID = EF2BYTE( *(__le16 *)&hwinfo[EEPROM_VID_88EU] ); - pHalData->EEPROMPID = EF2BYTE( *(__le16 *)&hwinfo[EEPROM_PID_88EU] ); + haldata->EEPROMVID = EF2BYTE(*(__le16 *)&hwinfo[EEPROM_VID_88EU]); + haldata->EEPROMPID = EF2BYTE(*(__le16 *)&hwinfo[EEPROM_PID_88EU]); /* Customer ID, 0x00 and 0xff are reserved for Realtek. */ - pHalData->EEPROMCustomerID = *(u8 *)&hwinfo[EEPROM_CUSTOMERID_88E]; - pHalData->EEPROMSubCustomerID = EEPROM_Default_SubCustomerID; - - } - else - { - pHalData->EEPROMVID = EEPROM_Default_VID; - pHalData->EEPROMPID = EEPROM_Default_PID; + haldata->EEPROMCustomerID = *(u8 *)&hwinfo[EEPROM_CUSTOMERID_88E]; + haldata->EEPROMSubCustomerID = EEPROM_Default_SubCustomerID; + } else { + haldata->EEPROMVID = EEPROM_Default_VID; + haldata->EEPROMPID = EEPROM_Default_PID; /* Customer ID, 0x00 and 0xff are reserved for Realtek. */ - pHalData->EEPROMCustomerID = EEPROM_Default_CustomerID; - pHalData->EEPROMSubCustomerID = EEPROM_Default_SubCustomerID; - + haldata->EEPROMCustomerID = EEPROM_Default_CustomerID; + haldata->EEPROMSubCustomerID = EEPROM_Default_SubCustomerID; } - DBG_88E("VID = 0x%04X, PID = 0x%04X\n", pHalData->EEPROMVID, pHalData->EEPROMPID); - DBG_88E("Customer ID: 0x%02X, SubCustomer ID: 0x%02X\n", pHalData->EEPROMCustomerID, pHalData->EEPROMSubCustomerID); + DBG_88E("VID = 0x%04X, PID = 0x%04X\n", haldata->EEPROMVID, haldata->EEPROMPID); + DBG_88E("Customer ID: 0x%02X, SubCustomer ID: 0x%02X\n", haldata->EEPROMCustomerID, haldata->EEPROMSubCustomerID); } -static void -Hal_EfuseParseMACAddr_8188EU( - struct adapter * padapter, - u8* hwinfo, - bool AutoLoadFail - ) +static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) { - u16 i, usValue; - u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x88, 0x02}; - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + u16 i, usValue; + u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x88, 0x02}; + struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); - if (AutoLoadFail) - { -/* sMacAddr[5] = (u1Byte)GetRandomNumber(1, 254); */ - for (i=0; i<6; i++) - pEEPROM->mac_addr[i] = sMacAddr[i]; - } - else - { + if (AutoLoadFail) { + for (i = 0; i < 6; i++) + eeprom->mac_addr[i] = sMacAddr[i]; + } else { /* Read Permanent MAC address */ - _rtw_memcpy(pEEPROM->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN); - + _rtw_memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN); } - RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, - ("Hal_EfuseParseMACAddr_8188EU: Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", - pEEPROM->mac_addr[0], pEEPROM->mac_addr[1], - pEEPROM->mac_addr[2], pEEPROM->mac_addr[3], - pEEPROM->mac_addr[4], pEEPROM->mac_addr[5])); + ("Hal_EfuseParseMACAddr_8188EU: Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", + eeprom->mac_addr[0], eeprom->mac_addr[1], + eeprom->mac_addr[2], eeprom->mac_addr[3], + eeprom->mac_addr[4], eeprom->mac_addr[5])); } - -static void -Hal_CustomizeByCustomerID_8188EU( - struct adapter * padapter - ) +static void Hal_CustomizeByCustomerID_8188EU(struct adapter *adapt) { } /* Read HW power down mode selection */ -static void _ReadPSSetting(struct adapter * Adapter, u8 *PROMContent, u8 AutoloadFail) +static void _ReadPSSetting(struct adapter *Adapter, u8 *PROMContent, u8 AutoloadFail) { } static void readAdapterInfo_8188EU( - struct adapter * padapter + struct adapter *adapt ) { - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); /* parse the eeprom/efuse content */ - Hal_EfuseParseIDCode88E(padapter, pEEPROM->efuse_eeprom_data); - Hal_EfuseParsePIDVID_8188EU(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); - Hal_EfuseParseMACAddr_8188EU(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); + Hal_EfuseParseIDCode88E(adapt, eeprom->efuse_eeprom_data); + Hal_EfuseParsePIDVID_8188EU(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseMACAddr_8188EU(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - Hal_ReadPowerSavingMode88E(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); - Hal_ReadTxPowerInfo88E(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); - Hal_EfuseParseEEPROMVer88E(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); - rtl8188e_EfuseParseChnlPlan(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); - Hal_EfuseParseXtal_8188E(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); - Hal_EfuseParseCustomerID88E(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); - Hal_ReadAntennaDiversity88E(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); - Hal_EfuseParseBoardType88E(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); - Hal_ReadThermalMeter_88E(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); + Hal_ReadPowerSavingMode88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_ReadTxPowerInfo88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseEEPROMVer88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + rtl8188e_EfuseParseChnlPlan(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseXtal_8188E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseCustomerID88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_ReadAntennaDiversity88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseBoardType88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_ReadThermalMeter_88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); /* */ /* The following part initialize some vars by PG info. */ /* */ - Hal_InitChannelPlan(padapter); - Hal_CustomizeByCustomerID_8188EU(padapter); + Hal_InitChannelPlan(adapt); + Hal_CustomizeByCustomerID_8188EU(adapt); - _ReadLEDSetting(padapter, pEEPROM->efuse_eeprom_data, pEEPROM->bautoload_fail_flag); + _ReadLEDSetting(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); } static void _ReadPROMContent( - struct adapter * Adapter + struct adapter *Adapter ) { - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(Adapter); - u8 eeValue; + struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(Adapter); + u8 eeValue; /* check system boot selection */ eeValue = rtw_read8(Adapter, REG_9346CR); - pEEPROM->EepromOrEfuse = (eeValue & BOOT_FROM_EEPROM) ? true : false; - pEEPROM->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true; + eeprom->EepromOrEfuse = (eeValue & BOOT_FROM_EEPROM) ? true : false; + eeprom->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true; - - DBG_88E("Boot from %s, Autoload %s !\n", (pEEPROM->EepromOrEfuse ? "EEPROM" : "EFUSE"), - (pEEPROM->bautoload_fail_flag ? "Fail" : "OK") ); + DBG_88E("Boot from %s, Autoload %s !\n", (eeprom->EepromOrEfuse ? "EEPROM" : "EFUSE"), + (eeprom->bautoload_fail_flag ? "Fail" : "OK")); Hal_InitPGData88E(Adapter); readAdapterInfo_8188EU(Adapter); } - - -static void -_ReadRFType( - struct adapter * Adapter - ) +static void _ReadRFType(struct adapter *Adapter) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); - pHalData->rf_chip = RF_6052; + haldata->rf_chip = RF_6052; } -static int _ReadAdapterInfo8188EU(struct adapter * Adapter) +static int _ReadAdapterInfo8188EU(struct adapter *Adapter) { - u32 start=rtw_get_current_time(); + u32 start = rtw_get_current_time(); MSG_88E("====> %s\n", __func__); @@ -1818,8 +1523,7 @@ static int _ReadAdapterInfo8188EU(struct adapter * Adapter) return _SUCCESS; } - -static void ReadAdapterInfo8188EU(struct adapter * Adapter) +static void ReadAdapterInfo8188EU(struct adapter *Adapter) { /* Read EEPROM size before call any EEPROM function */ Adapter->EepromAddressSize = GetEEPROMSize8188E(Adapter); @@ -1827,37 +1531,36 @@ static void ReadAdapterInfo8188EU(struct adapter * Adapter) _ReadAdapterInfo8188EU(Adapter); } - #define GPIO_DEBUG_PORT_NUM 0 -static void rtl8192cu_trigger_gpio_0(struct adapter *padapter) +static void rtl8192cu_trigger_gpio_0(struct adapter *adapt) { } -static void ResumeTxBeacon(struct adapter *padapter) +static void ResumeTxBeacon(struct adapter *adapt) { - struct hal_data_8188e* pHalData = GET_HAL_DATA(padapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ /* which should be read from register to a global variable. */ - rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, (pHalData->RegFwHwTxQCtrl) | BIT6); - pHalData->RegFwHwTxQCtrl |= BIT6; - rtw_write8(padapter, REG_TBTT_PROHIBIT+1, 0xff); - pHalData->RegReg542 |= BIT0; - rtw_write8(padapter, REG_TBTT_PROHIBIT+2, pHalData->RegReg542); + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) | BIT6); + haldata->RegFwHwTxQCtrl |= BIT6; + rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0xff); + haldata->RegReg542 |= BIT0; + rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); } -static void UpdateInterruptMask8188EU(struct adapter * padapter,u8 bHIMR0 ,u32 AddMSR, u32 RemoveMSR) +static void UpdateInterruptMask8188EU(struct adapter *adapt, u8 bHIMR0 , u32 AddMSR, u32 RemoveMSR) { - struct hal_data_8188e *pHalData; + struct hal_data_8188e *haldata; u32 *himr; - pHalData = GET_HAL_DATA(padapter); + haldata = GET_HAL_DATA(adapt); if (bHIMR0) - himr = &(pHalData->IntrMask[0]); + himr = &(haldata->IntrMask[0]); else - himr = &(pHalData->IntrMask[1]); + himr = &(haldata->IntrMask[1]); if (AddMSR) *himr |= AddMSR; @@ -1866,118 +1569,107 @@ static void UpdateInterruptMask8188EU(struct adapter * padapter,u8 bHIMR0 ,u32 A *himr &= (~RemoveMSR); if (bHIMR0) - rtw_write32(padapter, REG_HIMR_88E, *himr); + rtw_write32(adapt, REG_HIMR_88E, *himr); else - rtw_write32(padapter, REG_HIMRE_88E, *himr); - + rtw_write32(adapt, REG_HIMRE_88E, *himr); } -static void StopTxBeacon(struct adapter *padapter) +static void StopTxBeacon(struct adapter *adapt) { - struct hal_data_8188e* pHalData = GET_HAL_DATA(padapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ /* which should be read from register to a global variable. */ - rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, (pHalData->RegFwHwTxQCtrl) & (~BIT6)); - pHalData->RegFwHwTxQCtrl &= (~BIT6); - rtw_write8(padapter, REG_TBTT_PROHIBIT+1, 0x64); - pHalData->RegReg542 &= ~(BIT0); - rtw_write8(padapter, REG_TBTT_PROHIBIT+2, pHalData->RegReg542); + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) & (~BIT6)); + haldata->RegFwHwTxQCtrl &= (~BIT6); + rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0x64); + haldata->RegReg542 &= ~(BIT0); + rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); /* todo: CheckFwRsvdPageContent(Adapter); 2010.06.23. Added by tynli. */ - } - -static void hw_var_set_opmode(struct adapter * Adapter, u8 variable, u8* val) +static void hw_var_set_opmode(struct adapter *Adapter, u8 variable, u8 *val) { - u8 val8; - u8 mode = *((u8 *)val); + u8 val8; + u8 mode = *((u8 *)val); - { - /* disable Port0 TSF update */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + /* disable Port0 TSF update */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); - /* set net_type */ - val8 = rtw_read8(Adapter, MSR)&0x0c; - val8 |= mode; - rtw_write8(Adapter, MSR, val8); + /* set net_type */ + val8 = rtw_read8(Adapter, MSR)&0x0c; + val8 |= mode; + rtw_write8(Adapter, MSR, val8); - DBG_88E("%s()-%d mode = %d\n", __func__, __LINE__, mode); + DBG_88E("%s()-%d mode = %d\n", __func__, __LINE__, mode); - if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) - { - StopTxBeacon(Adapter); + if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) { + StopTxBeacon(Adapter); - rtw_write8(Adapter,REG_BCN_CTRL, 0x19);/* disable atim wnd */ - } - else if ((mode == _HW_STATE_ADHOC_) /*|| (mode == _HW_STATE_AP_)*/) - { - ResumeTxBeacon(Adapter); - rtw_write8(Adapter,REG_BCN_CTRL, 0x1a); - } - else if (mode == _HW_STATE_AP_) - { + rtw_write8(Adapter, REG_BCN_CTRL, 0x19);/* disable atim wnd */ + } else if ((mode == _HW_STATE_ADHOC_)) { + ResumeTxBeacon(Adapter); + rtw_write8(Adapter, REG_BCN_CTRL, 0x1a); + } else if (mode == _HW_STATE_AP_) { + ResumeTxBeacon(Adapter); - ResumeTxBeacon(Adapter); + rtw_write8(Adapter, REG_BCN_CTRL, 0x12); - rtw_write8(Adapter, REG_BCN_CTRL, 0x12); + /* Set RCR */ + rtw_write32(Adapter, REG_RCR, 0x7000208e);/* CBSSID_DATA must set to 0,reject ICV_ERR packet */ + /* enable to rx data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + /* enable to rx ps-poll */ + rtw_write16(Adapter, REG_RXFLTMAP1, 0x0400); - /* Set RCR */ - rtw_write32(Adapter, REG_RCR, 0x7000208e);/* CBSSID_DATA must set to 0,reject ICV_ERR packet */ - /* enable to rx data frame */ - rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); - /* enable to rx ps-poll */ - rtw_write16(Adapter, REG_RXFLTMAP1, 0x0400); + /* Beacon Control related register for first time */ + rtw_write8(Adapter, REG_BCNDMATIM, 0x02); /* 2ms */ - /* Beacon Control related register for first time */ - rtw_write8(Adapter, REG_BCNDMATIM, 0x02); /* 2ms */ + rtw_write8(Adapter, REG_ATIMWND, 0x0a); /* 10ms */ + rtw_write16(Adapter, REG_BCNTCFG, 0x00); + rtw_write16(Adapter, REG_TBTT_PROHIBIT, 0xff04); + rtw_write16(Adapter, REG_TSFTR_SYN_OFFSET, 0x7fff);/* +32767 (~32ms) */ - rtw_write8(Adapter, REG_ATIMWND, 0x0a); /* 10ms */ - rtw_write16(Adapter, REG_BCNTCFG, 0x00); - rtw_write16(Adapter, REG_TBTT_PROHIBIT, 0xff04); - rtw_write16(Adapter, REG_TSFTR_SYN_OFFSET, 0x7fff);/* +32767 (~32ms) */ + /* reset TSF */ + rtw_write8(Adapter, REG_DUAL_TSF_RST, BIT(0)); - /* reset TSF */ - rtw_write8(Adapter, REG_DUAL_TSF_RST, BIT(0)); + /* BIT3 - If set 0, hw will clr bcnq when tx becon ok/fail or port 0 */ + rtw_write8(Adapter, REG_MBID_NUM, rtw_read8(Adapter, REG_MBID_NUM) | BIT(3) | BIT(4)); - /* BIT3 - If set 0, hw will clr bcnq when tx becon ok/fail or port 0 */ - rtw_write8(Adapter, REG_MBID_NUM, rtw_read8(Adapter, REG_MBID_NUM)|BIT(3)|BIT(4)); + /* enable BCN0 Function for if1 */ + /* don't enable update TSF0 for if1 (due to TSF update when beacon/probe rsp are received) */ + rtw_write8(Adapter, REG_BCN_CTRL, (DIS_TSF_UDT0_NORMAL_CHIP|EN_BCN_FUNCTION | BIT(1))); - /* enable BCN0 Function for if1 */ - /* don't enable update TSF0 for if1 (due to TSF update when beacon/probe rsp are received) */ - rtw_write8(Adapter, REG_BCN_CTRL, (DIS_TSF_UDT0_NORMAL_CHIP|EN_BCN_FUNCTION |BIT(1))); - - /* dis BCN1 ATIM WND if if2 is station */ - rtw_write8(Adapter, REG_BCN_CTRL_1, rtw_read8(Adapter, REG_BCN_CTRL_1)|BIT(0)); - } + /* dis BCN1 ATIM WND if if2 is station */ + rtw_write8(Adapter, REG_BCN_CTRL_1, rtw_read8(Adapter, REG_BCN_CTRL_1) | BIT(0)); } } -static void hw_var_set_macaddr(struct adapter * Adapter, u8 variable, u8* val) +static void hw_var_set_macaddr(struct adapter *Adapter, u8 variable, u8 *val) { u8 idx = 0; u32 reg_macid; reg_macid = REG_MACID; - for (idx = 0 ; idx < 6; idx++) + for (idx = 0; idx < 6; idx++) rtw_write8(Adapter, (reg_macid+idx), val[idx]); } -static void hw_var_set_bssid(struct adapter * Adapter, u8 variable, u8* val) +static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val) { - u8 idx = 0; + u8 idx = 0; u32 reg_bssid; reg_bssid = REG_BSSID; - for (idx = 0 ; idx < 6; idx++) + for (idx = 0; idx < 6; idx++) rtw_write8(Adapter, (reg_bssid+idx), val[idx]); } -static void hw_var_set_bcn_func(struct adapter * Adapter, u8 variable, u8* val) +static void hw_var_set_bcn_func(struct adapter *Adapter, u8 variable, u8 *val) { u32 bcn_ctrl_reg; @@ -1989,882 +1681,807 @@ static void hw_var_set_bcn_func(struct adapter * Adapter, u8 variable, u8* val) rtw_write8(Adapter, bcn_ctrl_reg, rtw_read8(Adapter, bcn_ctrl_reg)&(~(EN_BCN_FUNCTION | EN_TXBCN_RPT))); } -static void hw_var_set_correct_tsf(struct adapter * Adapter, u8 variable, u8* val) +static void hw_var_set_correct_tsf(struct adapter *Adapter, u8 variable, u8 *val) { } -static void hw_var_set_mlme_disconnect(struct adapter * Adapter, u8 variable, u8* val) +static void hw_var_set_mlme_disconnect(struct adapter *Adapter, u8 variable, u8 *val) { } -static void hw_var_set_mlme_sitesurvey(struct adapter * Adapter, u8 variable, u8* val) +static void hw_var_set_mlme_sitesurvey(struct adapter *Adapter, u8 variable, u8 *val) { } -static void hw_var_set_mlme_join(struct adapter * Adapter, u8 variable, u8* val) +static void hw_var_set_mlme_join(struct adapter *Adapter, u8 variable, u8 *val) { } -static void SetHwReg8188EU(struct adapter * Adapter, u8 variable, u8* val) +static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - struct odm_dm_struct *podmpriv = &pHalData->odmpriv; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &haldata->dmpriv; + struct odm_dm_struct *podmpriv = &haldata->odmpriv; _func_enter_; - switch (variable) - { - case HW_VAR_MEDIA_STATUS: - { - u8 val8; - - val8 = rtw_read8(Adapter, MSR)&0x0c; - val8 |= *((u8 *)val); - rtw_write8(Adapter, MSR, val8); - } - break; - case HW_VAR_MEDIA_STATUS1: - { - u8 val8; - - val8 = rtw_read8(Adapter, MSR)&0x03; - val8 |= *((u8 *)val) <<2; - rtw_write8(Adapter, MSR, val8); - } - break; - case HW_VAR_SET_OPMODE: - hw_var_set_opmode(Adapter, variable, val); - break; - case HW_VAR_MAC_ADDR: - hw_var_set_macaddr(Adapter, variable, val); - break; - case HW_VAR_BSSID: - hw_var_set_bssid(Adapter, variable, val); - break; - case HW_VAR_BASIC_RATE: - { - u16 BrateCfg = 0; - u8 RateIndex = 0; - - /* 2007.01.16, by Emily */ - /* Select RRSR (in Legacy-OFDM and CCK) */ - /* For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, 2M, and 1M from the Basic rate. */ - /* We do not use other rates. */ - HalSetBrateCfg( Adapter, val, &BrateCfg ); - DBG_88E("HW_VAR_BASIC_RATE: BrateCfg(%#x)\n", BrateCfg); - - /* 2011.03.30 add by Luke Lee */ - /* CCK 2M ACK should be disabled for some BCM and Atheros AP IOT */ - /* because CCK 2M has poor TXEVM */ - /* CCK 5.5M & 11M ACK should be enabled for better performance */ - - pHalData->BasicRateSet = BrateCfg = (BrateCfg |0xd) & 0x15d; - - BrateCfg |= 0x01; /* default enable 1M ACK rate */ - /* Set RRSR rate table. */ - rtw_write8(Adapter, REG_RRSR, BrateCfg&0xff); - rtw_write8(Adapter, REG_RRSR+1, (BrateCfg>>8)&0xff); - rtw_write8(Adapter, REG_RRSR+2, rtw_read8(Adapter, REG_RRSR+2)&0xf0); - - /* Set RTS initial rate */ - while (BrateCfg > 0x1) - { - BrateCfg = (BrateCfg>> 1); - RateIndex++; - } - /* Ziv - Check */ - rtw_write8(Adapter, REG_INIRTS_RATE_SEL, RateIndex); - } - break; - case HW_VAR_TXPAUSE: - rtw_write8(Adapter, REG_TXPAUSE, *((u8 *)val)); - break; - case HW_VAR_BCN_FUNC: - hw_var_set_bcn_func(Adapter, variable, val); - break; - case HW_VAR_CORRECT_TSF: - { - u64 tsf; - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - - tsf = pmlmeext->TSFValue - rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) -1024; /* us */ - - if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) - { - StopTxBeacon(Adapter); - } - - /* disable related TSF function */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(3))); - - rtw_write32(Adapter, REG_TSFTR, tsf); - rtw_write32(Adapter, REG_TSFTR+4, tsf>>32); - - /* enable related TSF function */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(3)); - - - if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) - { - ResumeTxBeacon(Adapter); - } - } - break; - case HW_VAR_CHECK_BSSID: - if (*((u8 *)val)) - { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); - } - else - { - u32 val32; - - val32 = rtw_read32(Adapter, REG_RCR); - - val32 &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN); - - rtw_write32(Adapter, REG_RCR, val32); - } - break; - case HW_VAR_MLME_DISCONNECT: - { - /* Set RCR to not to receive data frame when NO LINK state */ - /* reject all data frames */ - rtw_write16(Adapter, REG_RXFLTMAP2,0x00); - - /* reset TSF */ - rtw_write8(Adapter, REG_DUAL_TSF_RST, (BIT(0)|BIT(1))); - - /* disable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); - } - break; - case HW_VAR_MLME_SITESURVEY: - if (*((u8 *)val))/* under sitesurvey */ - { - /* config RCR to receive different BSSID & not to receive data frame */ - u32 v = rtw_read32(Adapter, REG_RCR); - v &= ~(RCR_CBSSID_BCN); - rtw_write32(Adapter, REG_RCR, v); - /* reject all data frame */ - rtw_write16(Adapter, REG_RXFLTMAP2,0x00); - - /* disable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); - } - else/* sitesurvey done */ - { - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - - if ((is_client_associated_to_ap(Adapter) == true) || - ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) ) - { - /* enable to rx data frame */ - rtw_write16(Adapter, REG_RXFLTMAP2,0xFFFF); - - /* enable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); - } - else if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) - { - rtw_write16(Adapter, REG_RXFLTMAP2,0xFFFF); - - /* enable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); - } - - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); - else - { - if (Adapter->in_cta_test) - { - u32 v = rtw_read32(Adapter, REG_RCR); - v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN );/* RCR_ADF */ - rtw_write32(Adapter, REG_RCR, v); - } - else - { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); - } - } - } - break; - case HW_VAR_MLME_JOIN: - { - u8 RetryLimit = 0x30; - u8 type = *((u8 *)val); - struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - - if (type == 0) /* prepare to join */ - { - /* enable to rx data frame.Accept all data frame */ - rtw_write16(Adapter, REG_RXFLTMAP2,0xFFFF); - - if (Adapter->in_cta_test) - { - u32 v = rtw_read32(Adapter, REG_RCR); - v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN );/* RCR_ADF */ - rtw_write32(Adapter, REG_RCR, v); - } - else - { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); - } - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) - { - RetryLimit = (pHalData->CustomerID == RT_CID_CCX) ? 7 : 48; - } - else /* Ad-hoc Mode */ - { - RetryLimit = 0x7; - } - } - else if (type == 1) /* joinbss_event call back when join res < 0 */ - { - rtw_write16(Adapter, REG_RXFLTMAP2,0x00); - } - else if (type == 2) /* sta add event call back */ - { - /* enable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) - { - RetryLimit = 0x7; - } - } - - rtw_write16(Adapter, REG_RL, RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << RETRY_LIMIT_LONG_SHIFT); - } - break; - case HW_VAR_BEACON_INTERVAL: - rtw_write16(Adapter, REG_BCN_INTERVAL, *((u16 *)val)); - break; - case HW_VAR_SLOT_TIME: - { - u8 u1bAIFS, aSifsTime; - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - - rtw_write8(Adapter, REG_SLOT, val[0]); - - if (pmlmeinfo->WMM_enable == 0) - { - if ( pmlmeext->cur_wireless_mode == WIRELESS_11B) - aSifsTime = 10; - else - aSifsTime = 16; - - u1bAIFS = aSifsTime + (2 * pmlmeinfo->slotTime); - - /* Temporary removed, 2008.06.20. */ - rtw_write8(Adapter, REG_EDCA_VO_PARAM, u1bAIFS); - rtw_write8(Adapter, REG_EDCA_VI_PARAM, u1bAIFS); - rtw_write8(Adapter, REG_EDCA_BE_PARAM, u1bAIFS); - rtw_write8(Adapter, REG_EDCA_BK_PARAM, u1bAIFS); - } - } - break; - case HW_VAR_RESP_SIFS: - /* RESP_SIFS for CCK */ - rtw_write8(Adapter, REG_R2T_SIFS, val[0]); /* SIFS_T2T_CCK (0x08) */ - rtw_write8(Adapter, REG_R2T_SIFS+1, val[1]); /* SIFS_R2T_CCK(0x08) */ - /* RESP_SIFS for OFDM */ - rtw_write8(Adapter, REG_T2T_SIFS, val[2]); /* SIFS_T2T_OFDM (0x0a) */ - rtw_write8(Adapter, REG_T2T_SIFS+1, val[3]); /* SIFS_R2T_OFDM(0x0a) */ - break; - case HW_VAR_ACK_PREAMBLE: - { - u8 regTmp; - u8 bShortPreamble = *( (bool *)val ); - /* Joseph marked out for Netgear 3500 TKIP channel 7 issue.(Temporarily) */ - regTmp = (pHalData->nCur40MhzPrimeSC)<<5; - if (bShortPreamble) - regTmp |= 0x80; - - rtw_write8(Adapter, REG_RRSR+2, regTmp); - } - break; - case HW_VAR_SEC_CFG: - rtw_write8(Adapter, REG_SECCFG, *((u8 *)val)); - break; - case HW_VAR_DM_FLAG: - podmpriv->SupportAbility = *((u8 *)val); - break; - case HW_VAR_DM_FUNC_OP: - if (val[0]) - {/* save dm flag */ - podmpriv->BK_SupportAbility = podmpriv->SupportAbility; - } - else - {/* restore dm flag */ - podmpriv->SupportAbility = podmpriv->BK_SupportAbility; - } - break; - case HW_VAR_DM_FUNC_SET: - if (*((u32 *)val) == DYNAMIC_ALL_FUNC_ENABLE){ - pdmpriv->DMFlag = pdmpriv->InitDMFlag; - podmpriv->SupportAbility = pdmpriv->InitODMFlag; - } - else{ - podmpriv->SupportAbility |= *((u32 *)val); - } - break; - case HW_VAR_DM_FUNC_CLR: - podmpriv->SupportAbility &= *((u32 *)val); - break; - - case HW_VAR_CAM_EMPTY_ENTRY: - { - u8 ucIndex = *((u8 *)val); - u8 i; - u32 ulCommand=0; - u32 ulContent=0; - u32 ulEncAlgo=CAM_AES; - - for (i=0;iAcParam_BE = ((u32 *)(val))[0]; - rtw_write32(Adapter, REG_EDCA_BE_PARAM, ((u32 *)(val))[0]); - break; - case HW_VAR_AC_PARAM_BK: - rtw_write32(Adapter, REG_EDCA_BK_PARAM, ((u32 *)(val))[0]); - break; - case HW_VAR_ACM_CTRL: - { - u8 acm_ctrl = *((u8 *)val); - u8 AcmCtrl = rtw_read8( Adapter, REG_ACMHWCTRL); - - if (acm_ctrl > 1) - AcmCtrl = AcmCtrl | 0x1; - - if (acm_ctrl & BIT(3)) - AcmCtrl |= AcmHw_VoqEn; - else - AcmCtrl &= (~AcmHw_VoqEn); - - if (acm_ctrl & BIT(2)) - AcmCtrl |= AcmHw_ViqEn; - else - AcmCtrl &= (~AcmHw_ViqEn); - - if (acm_ctrl & BIT(1)) - AcmCtrl |= AcmHw_BeqEn; - else - AcmCtrl &= (~AcmHw_BeqEn); - - DBG_88E("[HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl ); - rtw_write8(Adapter, REG_ACMHWCTRL, AcmCtrl ); - } - break; - case HW_VAR_AMPDU_MIN_SPACE: - { - u8 MinSpacingToSet; - u8 SecMinSpace; - - MinSpacingToSet = *((u8 *)val); - if (MinSpacingToSet <= 7) - { - switch (Adapter->securitypriv.dot11PrivacyAlgrthm) - { - case _NO_PRIVACY_: - case _AES_: - SecMinSpace = 0; - break; - - case _WEP40_: - case _WEP104_: - case _TKIP_: - case _TKIP_WTMIC_: - SecMinSpace = 6; - break; - default: - SecMinSpace = 7; - break; - } - - if (MinSpacingToSet < SecMinSpace){ - MinSpacingToSet = SecMinSpace; - } - - rtw_write8(Adapter, REG_AMPDU_MIN_SPACE, (rtw_read8(Adapter, REG_AMPDU_MIN_SPACE) & 0xf8) | MinSpacingToSet); - } - } - break; - case HW_VAR_AMPDU_FACTOR: - { - u8 RegToSet_Normal[4]={0x41,0xa8,0x72, 0xb9}; - u8 RegToSet_BT[4]={0x31,0x74,0x42, 0x97}; - u8 FactorToSet; - u8 *pRegToSet; - u8 index = 0; - -#ifdef CONFIG_BT_COEXIST - if ( (pHalData->bt_coexist.BT_Coexist) && - (pHalData->bt_coexist.BT_CoexistType == BT_CSR_BC4) ) - pRegToSet = RegToSet_BT; /* 0x97427431; */ - else -#endif - pRegToSet = RegToSet_Normal; /* 0xb972a841; */ - - FactorToSet = *((u8 *)val); - if (FactorToSet <= 3) - { - FactorToSet = (1<<(FactorToSet + 2)); - if (FactorToSet>0xf) - FactorToSet = 0xf; - - for (index=0; index<4; index++) - { - if ((pRegToSet[index] & 0xf0) > (FactorToSet<<4)) - pRegToSet[index] = (pRegToSet[index] & 0x0f) | (FactorToSet<<4); - - if ((pRegToSet[index] & 0x0f) > FactorToSet) - pRegToSet[index] = (pRegToSet[index] & 0xf0) | (FactorToSet); - - rtw_write8(Adapter, (REG_AGGLEN_LMT+index), pRegToSet[index]); - } - - } - } - break; - case HW_VAR_RXDMA_AGG_PG_TH: - { - u8 threshold = *((u8 *)val); - if ( threshold == 0) - { - threshold = pHalData->UsbRxAggPageCount; - } - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, threshold); - } - break; - case HW_VAR_SET_RPWM: - break; - case HW_VAR_H2C_FW_PWRMODE: - { - u8 psmode = (*(u8 *)val); - - /* Forece leave RF low power mode for 1T1R to prevent conficting setting in Fw power */ - /* saving sequence. 2010.06.07. Added by tynli. Suggested by SD3 yschang. */ - if ( (psmode != PS_MODE_ACTIVE) && (!IS_92C_SERIAL(pHalData->VersionID))) - ODM_RF_Saving(podmpriv, true); - rtl8188e_set_FwPwrMode_cmd(Adapter, psmode); - } - break; - case HW_VAR_H2C_FW_JOINBSSRPT: - { - u8 mstatus = (*(u8 *)val); - rtl8188e_set_FwJoinBssReport_cmd(Adapter, mstatus); - } - break; - case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: - { - u8 p2p_ps_state = (*(u8 *)val); - rtl8188e_set_p2p_ps_offload_cmd(Adapter, p2p_ps_state); - } - break; - case HW_VAR_INITIAL_GAIN: - { - struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; - u32 rx_gain = ((u32 *)(val))[0]; - - if (rx_gain == 0xff){/* restore rx gain */ - ODM_Write_DIG(podmpriv,pDigTable->BackupIGValue); - } - else{ - pDigTable->BackupIGValue = pDigTable->CurIGValue; - ODM_Write_DIG(podmpriv,rx_gain); - } - } - break; - case HW_VAR_TRIGGER_GPIO_0: - rtl8192cu_trigger_gpio_0(Adapter); - break; -#ifdef CONFIG_BT_COEXIST - case HW_VAR_BT_SET_COEXIST: - { - u8 bStart = (*(u8 *)val); - rtl8192c_set_dm_bt_coexist(Adapter, bStart); - } - break; - case HW_VAR_BT_ISSUE_DELBA: - { - u8 dir = (*(u8 *)val); - rtl8192c_issue_delete_ba(Adapter, dir); - } - break; -#endif - case HW_VAR_RPT_TIMER_SETTING: - { - u16 min_rpt_time = (*(u16 *)val); - ODM_RA_Set_TxRPT_Time(podmpriv,min_rpt_time); - } - break; - case HW_VAR_ANTENNA_DIVERSITY_SELECT: - { - u8 Optimum_antenna = (*(u8 *)val); - u8 Ant ; - /* switch antenna to Optimum_antenna */ - if (pHalData->CurAntenna != Optimum_antenna) { - Ant = (Optimum_antenna==2)?MAIN_ANT:AUX_ANT; - ODM_UpdateRxIdleAnt_88E(&pHalData->odmpriv, Ant); - - pHalData->CurAntenna = Optimum_antenna ; - } - } - break; - case HW_VAR_EFUSE_BYTES: /* To set EFUE total used bytes, added by Roger, 2008.12.22. */ - pHalData->EfuseUsedBytes = *((u16 *)val); - break; - case HW_VAR_FIFO_CLEARN_UP: - { - struct pwrctrl_priv *pwrpriv = &Adapter->pwrctrlpriv; - u8 trycnt = 100; - - /* pause tx */ - rtw_write8(Adapter,REG_TXPAUSE,0xff); - - /* keep sn */ - Adapter->xmitpriv.nqos_ssn = rtw_read16(Adapter,REG_NQOS_SEQ); - - if (pwrpriv->bkeepfwalive != true) - { - /* RX DMA stop */ - rtw_write32(Adapter,REG_RXPKT_NUM,(rtw_read32(Adapter,REG_RXPKT_NUM)|RW_RELEASE_EN)); - do{ - if (!(rtw_read32(Adapter,REG_RXPKT_NUM)&RXDMA_IDLE)) - break; - }while (trycnt--); - if (trycnt ==0) - DBG_88E("Stop RX DMA failed......\n"); - - /* RQPN Load 0 */ - rtw_write16(Adapter,REG_RQPN_NPQ,0x0); - rtw_write32(Adapter,REG_RQPN,0x80000000); - rtw_mdelay_os(10); - } - } - break; - case HW_VAR_CHECK_TXBUF: - break; - case HW_VAR_APFM_ON_MAC: - pHalData->bMacPwrCtrlOn = *val; - DBG_88E("%s: bMacPwrCtrlOn=%d\n", __func__, pHalData->bMacPwrCtrlOn); - break; -#ifdef CONFIG_WOWLAN - case HW_VAR_WOWLAN: + switch (variable) { + case HW_VAR_MEDIA_STATUS: { - struct wowlan_ioctl_param *poidparam; - struct recv_buf *precvbuf; - int res, i; - u32 tmp; - u16 len = 0; - u8 mstatus = (*(u8 *)val); - u8 trycnt = 100; - u8 data[4]; + u8 val8; - poidparam = (struct wowlan_ioctl_param *)val; - switch (poidparam->subcode){ - case WOWLAN_ENABLE: - DBG_88E_LEVEL(_drv_always_, "WOWLAN_ENABLE\n"); + val8 = rtw_read8(Adapter, MSR)&0x0c; + val8 |= *((u8 *)val); + rtw_write8(Adapter, MSR, val8); + } + break; + case HW_VAR_MEDIA_STATUS1: + { + u8 val8; - SetFwRelatedForWoWLAN8188ES(Adapter, true); + val8 = rtw_read8(Adapter, MSR) & 0x03; + val8 |= *((u8 *)val) << 2; + rtw_write8(Adapter, MSR, val8); + } + break; + case HW_VAR_SET_OPMODE: + hw_var_set_opmode(Adapter, variable, val); + break; + case HW_VAR_MAC_ADDR: + hw_var_set_macaddr(Adapter, variable, val); + break; + case HW_VAR_BSSID: + hw_var_set_bssid(Adapter, variable, val); + break; + case HW_VAR_BASIC_RATE: + { + u16 BrateCfg = 0; + u8 RateIndex = 0; - /* RX DMA stop */ - DBG_88E_LEVEL(_drv_always_, "Pause DMA\n"); - rtw_write32(Adapter,REG_RXPKT_NUM,(rtw_read32(Adapter,REG_RXPKT_NUM)|RW_RELEASE_EN)); - do{ - if ((rtw_read32(Adapter, REG_RXPKT_NUM)&RXDMA_IDLE)) { - DBG_88E_LEVEL(_drv_always_, "RX_DMA_IDLE is true\n"); - break; - } else { - /* If RX_DMA is not idle, receive one pkt from DMA */ - DBG_88E_LEVEL(_drv_always_, "RX_DMA_IDLE is not true\n"); - } - }while (trycnt--); - if (trycnt ==0) - DBG_88E_LEVEL(_drv_always_, "Stop RX DMA failed......\n"); + /* 2007.01.16, by Emily */ + /* Select RRSR (in Legacy-OFDM and CCK) */ + /* For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, 2M, and 1M from the Basic rate. */ + /* We do not use other rates. */ + HalSetBrateCfg(Adapter, val, &BrateCfg); + DBG_88E("HW_VAR_BASIC_RATE: BrateCfg(%#x)\n", BrateCfg); - /* Set WOWLAN H2C command. */ - DBG_88E_LEVEL(_drv_always_, "Set WOWLan cmd\n"); - rtl8188es_set_wowlan_cmd(Adapter, 1); + /* 2011.03.30 add by Luke Lee */ + /* CCK 2M ACK should be disabled for some BCM and Atheros AP IOT */ + /* because CCK 2M has poor TXEVM */ + /* CCK 5.5M & 11M ACK should be enabled for better performance */ - mstatus = rtw_read8(Adapter, REG_WOW_CTRL); - trycnt = 10; + BrateCfg = (BrateCfg | 0xd) & 0x15d; + haldata->BasicRateSet = BrateCfg; - while (!(mstatus&BIT1) && trycnt>1) { - mstatus = rtw_read8(Adapter, REG_WOW_CTRL); - DBG_88E_LEVEL(_drv_info_, "Loop index: %d :0x%02x\n", trycnt, mstatus); - trycnt --; - rtw_msleep_os(2); - } + BrateCfg |= 0x01; /* default enable 1M ACK rate */ + /* Set RRSR rate table. */ + rtw_write8(Adapter, REG_RRSR, BrateCfg & 0xff); + rtw_write8(Adapter, REG_RRSR+1, (BrateCfg >> 8) & 0xff); + rtw_write8(Adapter, REG_RRSR+2, rtw_read8(Adapter, REG_RRSR+2)&0xf0); - Adapter->pwrctrlpriv.wowlan_wake_reason = rtw_read8(Adapter, REG_WOWLAN_WAKE_REASON); - DBG_88E_LEVEL(_drv_always_, "wowlan_wake_reason: 0x%02x\n", - Adapter->pwrctrlpriv.wowlan_wake_reason); + /* Set RTS initial rate */ + while (BrateCfg > 0x1) { + BrateCfg = (BrateCfg >> 1); + RateIndex++; + } + /* Ziv - Check */ + rtw_write8(Adapter, REG_INIRTS_RATE_SEL, RateIndex); + } + break; + case HW_VAR_TXPAUSE: + rtw_write8(Adapter, REG_TXPAUSE, *((u8 *)val)); + break; + case HW_VAR_BCN_FUNC: + hw_var_set_bcn_func(Adapter, variable, val); + break; + case HW_VAR_CORRECT_TSF: + { + u64 tsf; + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - /* Invoid SE0 reset signal during suspending*/ - rtw_write8(Adapter, REG_RSV_CTRL, 0x20); - rtw_write8(Adapter, REG_RSV_CTRL, 0x60); + tsf = pmlmeext->TSFValue - rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) - 1024; /* us */ - /* rtw_msleep_os(10); */ + if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) + StopTxBeacon(Adapter); + + /* disable related TSF function */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(3))); + + rtw_write32(Adapter, REG_TSFTR, tsf); + rtw_write32(Adapter, REG_TSFTR+4, tsf>>32); + + /* enable related TSF function */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(3)); + + if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) + ResumeTxBeacon(Adapter); + } + break; + case HW_VAR_CHECK_BSSID: + if (*((u8 *)val)) { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); + } else { + u32 val32; + + val32 = rtw_read32(Adapter, REG_RCR); + + val32 &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN); + + rtw_write32(Adapter, REG_RCR, val32); + } + break; + case HW_VAR_MLME_DISCONNECT: + /* Set RCR to not to receive data frame when NO LINK state */ + /* reject all data frames */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + + /* reset TSF */ + rtw_write8(Adapter, REG_DUAL_TSF_RST, (BIT(0)|BIT(1))); + + /* disable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + break; + case HW_VAR_MLME_SITESURVEY: + if (*((u8 *)val)) { /* under sitesurvey */ + /* config RCR to receive different BSSID & not to receive data frame */ + u32 v = rtw_read32(Adapter, REG_RCR); + v &= ~(RCR_CBSSID_BCN); + rtw_write32(Adapter, REG_RCR, v); + /* reject all data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + + /* disable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + } else { /* sitesurvey done */ + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((is_client_associated_to_ap(Adapter)) || + ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) { + /* enable to rx data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + + /* enable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + } else if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + /* enable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + } + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); + } else { + if (Adapter->in_cta_test) { + u32 v = rtw_read32(Adapter, REG_RCR); + v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ + rtw_write32(Adapter, REG_RCR, v); + } else { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); + } + } + } + break; + case HW_VAR_MLME_JOIN: + { + u8 RetryLimit = 0x30; + u8 type = *((u8 *)val); + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + + if (type == 0) { /* prepare to join */ + /* enable to rx data frame.Accept all data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + + if (Adapter->in_cta_test) { + u32 v = rtw_read32(Adapter, REG_RCR); + v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ + rtw_write32(Adapter, REG_RCR, v); + } else { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); + } + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + RetryLimit = (haldata->CustomerID == RT_CID_CCX) ? 7 : 48; + else /* Ad-hoc Mode */ + RetryLimit = 0x7; + } else if (type == 1) { + /* joinbss_event call back when join res < 0 */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + } else if (type == 2) { + /* sta add event call back */ + /* enable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) + RetryLimit = 0x7; + } + rtw_write16(Adapter, REG_RL, RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << RETRY_LIMIT_LONG_SHIFT); + } + break; + case HW_VAR_BEACON_INTERVAL: + rtw_write16(Adapter, REG_BCN_INTERVAL, *((u16 *)val)); + break; + case HW_VAR_SLOT_TIME: + { + u8 u1bAIFS, aSifsTime; + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + rtw_write8(Adapter, REG_SLOT, val[0]); + + if (pmlmeinfo->WMM_enable == 0) { + if (pmlmeext->cur_wireless_mode == WIRELESS_11B) + aSifsTime = 10; + else + aSifsTime = 16; + + u1bAIFS = aSifsTime + (2 * pmlmeinfo->slotTime); + + /* Temporary removed, 2008.06.20. */ + rtw_write8(Adapter, REG_EDCA_VO_PARAM, u1bAIFS); + rtw_write8(Adapter, REG_EDCA_VI_PARAM, u1bAIFS); + rtw_write8(Adapter, REG_EDCA_BE_PARAM, u1bAIFS); + rtw_write8(Adapter, REG_EDCA_BK_PARAM, u1bAIFS); + } + } + break; + case HW_VAR_RESP_SIFS: + /* RESP_SIFS for CCK */ + rtw_write8(Adapter, REG_R2T_SIFS, val[0]); /* SIFS_T2T_CCK (0x08) */ + rtw_write8(Adapter, REG_R2T_SIFS+1, val[1]); /* SIFS_R2T_CCK(0x08) */ + /* RESP_SIFS for OFDM */ + rtw_write8(Adapter, REG_T2T_SIFS, val[2]); /* SIFS_T2T_OFDM (0x0a) */ + rtw_write8(Adapter, REG_T2T_SIFS+1, val[3]); /* SIFS_R2T_OFDM(0x0a) */ + break; + case HW_VAR_ACK_PREAMBLE: + { + u8 regTmp; + u8 bShortPreamble = *((bool *)val); + /* Joseph marked out for Netgear 3500 TKIP channel 7 issue.(Temporarily) */ + regTmp = (haldata->nCur40MhzPrimeSC)<<5; + if (bShortPreamble) + regTmp |= 0x80; + + rtw_write8(Adapter, REG_RRSR+2, regTmp); + } + break; + case HW_VAR_SEC_CFG: + rtw_write8(Adapter, REG_SECCFG, *((u8 *)val)); + break; + case HW_VAR_DM_FLAG: + podmpriv->SupportAbility = *((u8 *)val); + break; + case HW_VAR_DM_FUNC_OP: + if (val[0]) + podmpriv->BK_SupportAbility = podmpriv->SupportAbility; + else + podmpriv->SupportAbility = podmpriv->BK_SupportAbility; + break; + case HW_VAR_DM_FUNC_SET: + if (*((u32 *)val) == DYNAMIC_ALL_FUNC_ENABLE) { + pdmpriv->DMFlag = pdmpriv->InitDMFlag; + podmpriv->SupportAbility = pdmpriv->InitODMFlag; + } else { + podmpriv->SupportAbility |= *((u32 *)val); + } + break; + case HW_VAR_DM_FUNC_CLR: + podmpriv->SupportAbility &= *((u32 *)val); + break; + case HW_VAR_CAM_EMPTY_ENTRY: + { + u8 ucIndex = *((u8 *)val); + u8 i; + u32 ulCommand = 0; + u32 ulContent = 0; + u32 ulEncAlgo = CAM_AES; + + for (i = 0; i < CAM_CONTENT_COUNT; i++) { + /* filled id in CAM config 2 byte */ + if (i == 0) + ulContent |= (ucIndex & 0x03) | ((u16)(ulEncAlgo)<<2); + else + ulContent = 0; + /* polling bit, and No Write enable, and address */ + ulCommand = CAM_CONTENT_COUNT*ucIndex+i; + ulCommand = ulCommand | CAM_POLLINIG|CAM_WRITE; + /* write content 0 is equall to mark invalid */ + rtw_write32(Adapter, WCAMI, ulContent); /* delay_ms(40); */ + rtw_write32(Adapter, RWCAM, ulCommand); /* delay_ms(40); */ + } + } + break; + case HW_VAR_CAM_INVALID_ALL: + rtw_write32(Adapter, RWCAM, BIT(31)|BIT(30)); + break; + case HW_VAR_CAM_WRITE: + { + u32 cmd; + u32 *cam_val = (u32 *)val; + rtw_write32(Adapter, WCAMI, cam_val[0]); + + cmd = CAM_POLLINIG | CAM_WRITE | cam_val[1]; + rtw_write32(Adapter, RWCAM, cmd); + } + break; + case HW_VAR_AC_PARAM_VO: + rtw_write32(Adapter, REG_EDCA_VO_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_AC_PARAM_VI: + rtw_write32(Adapter, REG_EDCA_VI_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_AC_PARAM_BE: + haldata->AcParam_BE = ((u32 *)(val))[0]; + rtw_write32(Adapter, REG_EDCA_BE_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_AC_PARAM_BK: + rtw_write32(Adapter, REG_EDCA_BK_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_ACM_CTRL: + { + u8 acm_ctrl = *((u8 *)val); + u8 AcmCtrl = rtw_read8(Adapter, REG_ACMHWCTRL); + + if (acm_ctrl > 1) + AcmCtrl = AcmCtrl | 0x1; + + if (acm_ctrl & BIT(3)) + AcmCtrl |= AcmHw_VoqEn; + else + AcmCtrl &= (~AcmHw_VoqEn); + + if (acm_ctrl & BIT(2)) + AcmCtrl |= AcmHw_ViqEn; + else + AcmCtrl &= (~AcmHw_ViqEn); + + if (acm_ctrl & BIT(1)) + AcmCtrl |= AcmHw_BeqEn; + else + AcmCtrl &= (~AcmHw_BeqEn); + + DBG_88E("[HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl); + rtw_write8(Adapter, REG_ACMHWCTRL, AcmCtrl); + } + break; + case HW_VAR_AMPDU_MIN_SPACE: + { + u8 MinSpacingToSet; + u8 SecMinSpace; + + MinSpacingToSet = *((u8 *)val); + if (MinSpacingToSet <= 7) { + switch (Adapter->securitypriv.dot11PrivacyAlgrthm) { + case _NO_PRIVACY_: + case _AES_: + SecMinSpace = 0; break; - case WOWLAN_DISABLE: - DBG_88E_LEVEL(_drv_always_, "WOWLAN_DISABLE\n"); - trycnt = 10; - rtl8188es_set_wowlan_cmd(Adapter, 0); - mstatus = rtw_read8(Adapter, REG_WOW_CTRL); - DBG_88E_LEVEL(_drv_info_, "%s mstatus:0x%02x\n", __func__, mstatus); - - while (mstatus&BIT1 && trycnt>1) { - mstatus = rtw_read8(Adapter, REG_WOW_CTRL); - DBG_88E_LEVEL(_drv_always_, "Loop index: %d :0x%02x\n", trycnt, mstatus); - trycnt --; - rtw_msleep_os(2); - } - - if (mstatus & BIT1) - printk("System did not release RX_DMA\n"); - else - SetFwRelatedForWoWLAN8188ES(Adapter, false); - - rtw_msleep_os(2); - if (!(Adapter->pwrctrlpriv.wowlan_wake_reason & FWDecisionDisconnect)) - rtl8188e_set_FwJoinBssReport_cmd(Adapter, 1); + case _WEP40_: + case _WEP104_: + case _TKIP_: + case _TKIP_WTMIC_: + SecMinSpace = 6; break; default: + SecMinSpace = 7; break; + } + if (MinSpacingToSet < SecMinSpace) + MinSpacingToSet = SecMinSpace; + rtw_write8(Adapter, REG_AMPDU_MIN_SPACE, (rtw_read8(Adapter, REG_AMPDU_MIN_SPACE) & 0xf8) | MinSpacingToSet); } } break; + case HW_VAR_AMPDU_FACTOR: + { + u8 RegToSet_Normal[4] = {0x41, 0xa8, 0x72, 0xb9}; + u8 RegToSet_BT[4] = {0x31, 0x74, 0x42, 0x97}; + u8 FactorToSet; + u8 *pRegToSet; + u8 index = 0; + +#ifdef CONFIG_BT_COEXIST + if ((haldata->bt_coexist.BT_Coexist) && + (haldata->bt_coexist.BT_CoexistType == BT_CSR_BC4)) + pRegToSet = RegToSet_BT; /* 0x97427431; */ + else +#endif + pRegToSet = RegToSet_Normal; /* 0xb972a841; */ + + FactorToSet = *((u8 *)val); + if (FactorToSet <= 3) { + FactorToSet = (1<<(FactorToSet + 2)); + if (FactorToSet > 0xf) + FactorToSet = 0xf; + + for (index = 0; index < 4; index++) { + if ((pRegToSet[index] & 0xf0) > (FactorToSet<<4)) + pRegToSet[index] = (pRegToSet[index] & 0x0f) | (FactorToSet<<4); + + if ((pRegToSet[index] & 0x0f) > FactorToSet) + pRegToSet[index] = (pRegToSet[index] & 0xf0) | (FactorToSet); + + rtw_write8(Adapter, (REG_AGGLEN_LMT+index), pRegToSet[index]); + } + } + } + break; + case HW_VAR_RXDMA_AGG_PG_TH: + { + u8 threshold = *((u8 *)val); + if (threshold == 0) + threshold = haldata->UsbRxAggPageCount; + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, threshold); + } + break; + case HW_VAR_SET_RPWM: + break; + case HW_VAR_H2C_FW_PWRMODE: + { + u8 psmode = (*(u8 *)val); + + /* Forece leave RF low power mode for 1T1R to prevent conficting setting in Fw power */ + /* saving sequence. 2010.06.07. Added by tynli. Suggested by SD3 yschang. */ + if ((psmode != PS_MODE_ACTIVE) && (!IS_92C_SERIAL(haldata->VersionID))) + ODM_RF_Saving(podmpriv, true); + rtl8188e_set_FwPwrMode_cmd(Adapter, psmode); + } + break; + case HW_VAR_H2C_FW_JOINBSSRPT: + { + u8 mstatus = (*(u8 *)val); + rtl8188e_set_FwJoinBssReport_cmd(Adapter, mstatus); + } + break; + case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: + { + u8 p2p_ps_state = (*(u8 *)val); + rtl8188e_set_p2p_ps_offload_cmd(Adapter, p2p_ps_state); + } + break; + case HW_VAR_INITIAL_GAIN: + { + struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; + u32 rx_gain = ((u32 *)(val))[0]; + + if (rx_gain == 0xff) {/* restore rx gain */ + ODM_Write_DIG(podmpriv, pDigTable->BackupIGValue); + } else { + pDigTable->BackupIGValue = pDigTable->CurIGValue; + ODM_Write_DIG(podmpriv, rx_gain); + } + } + break; + case HW_VAR_TRIGGER_GPIO_0: + rtl8192cu_trigger_gpio_0(Adapter); + break; +#ifdef CONFIG_BT_COEXIST + case HW_VAR_BT_SET_COEXIST: + { + u8 bStart = (*(u8 *)val); + rtl8192c_set_dm_bt_coexist(Adapter, bStart); + } + break; + case HW_VAR_BT_ISSUE_DELBA: + { + u8 dir = (*(u8 *)val); + rtl8192c_issue_delete_ba(Adapter, dir); + } + break; +#endif + case HW_VAR_RPT_TIMER_SETTING: + { + u16 min_rpt_time = (*(u16 *)val); + ODM_RA_Set_TxRPT_Time(podmpriv, min_rpt_time); + } + break; + case HW_VAR_ANTENNA_DIVERSITY_SELECT: + { + u8 Optimum_antenna = (*(u8 *)val); + u8 Ant; + /* switch antenna to Optimum_antenna */ + if (haldata->CurAntenna != Optimum_antenna) { + Ant = (Optimum_antenna == 2) ? MAIN_ANT : AUX_ANT; + ODM_UpdateRxIdleAnt_88E(&haldata->odmpriv, Ant); + + haldata->CurAntenna = Optimum_antenna; + } + } + break; + case HW_VAR_EFUSE_BYTES: /* To set EFUE total used bytes, added by Roger, 2008.12.22. */ + haldata->EfuseUsedBytes = *((u16 *)val); + break; + case HW_VAR_FIFO_CLEARN_UP: + { + struct pwrctrl_priv *pwrpriv = &Adapter->pwrctrlpriv; + u8 trycnt = 100; + + /* pause tx */ + rtw_write8(Adapter, REG_TXPAUSE, 0xff); + + /* keep sn */ + Adapter->xmitpriv.nqos_ssn = rtw_read16(Adapter, REG_NQOS_SEQ); + + if (!pwrpriv->bkeepfwalive) { + /* RX DMA stop */ + rtw_write32(Adapter, REG_RXPKT_NUM, (rtw_read32(Adapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); + do { + if (!(rtw_read32(Adapter, REG_RXPKT_NUM)&RXDMA_IDLE)) + break; + } while (trycnt--); + if (trycnt == 0) + DBG_88E("Stop RX DMA failed......\n"); + + /* RQPN Load 0 */ + rtw_write16(Adapter, REG_RQPN_NPQ, 0x0); + rtw_write32(Adapter, REG_RQPN, 0x80000000); + rtw_mdelay_os(10); + } + } + break; + case HW_VAR_CHECK_TXBUF: + break; + case HW_VAR_APFM_ON_MAC: + haldata->bMacPwrCtrlOn = *val; + DBG_88E("%s: bMacPwrCtrlOn=%d\n", __func__, haldata->bMacPwrCtrlOn); + break; +#ifdef CONFIG_WOWLAN + case HW_VAR_WOWLAN: + { + struct wowlan_ioctl_param *poidparam; + struct recv_buf *precvbuf; + int res, i; + u32 tmp; + u16 len = 0; + u8 mstatus = (*(u8 *)val); + u8 trycnt = 100; + u8 data[4]; + + poidparam = (struct wowlan_ioctl_param *)val; + switch (poidparam->subcode) { + case WOWLAN_ENABLE: + DBG_88E_LEVEL(_drv_always_, "WOWLAN_ENABLE\n"); + + SetFwRelatedForWoWLAN8188ES(Adapter, true); + + /* RX DMA stop */ + DBG_88E_LEVEL(_drv_always_, "Pause DMA\n"); + rtw_write32(Adapter, REG_RXPKT_NUM, (rtw_read32(Adapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); + do { + if ((rtw_read32(Adapter, REG_RXPKT_NUM)&RXDMA_IDLE)) { + DBG_88E_LEVEL(_drv_always_, "RX_DMA_IDLE is true\n"); + break; + } else { + /* If RX_DMA is not idle, receive one pkt from DMA */ + DBG_88E_LEVEL(_drv_always_, "RX_DMA_IDLE is not true\n"); + } + } while (trycnt--); + if (trycnt == 0) + DBG_88E_LEVEL(_drv_always_, "Stop RX DMA failed......\n"); + + /* Set WOWLAN H2C command. */ + DBG_88E_LEVEL(_drv_always_, "Set WOWLan cmd\n"); + rtl8188es_set_wowlan_cmd(Adapter, 1); + + mstatus = rtw_read8(Adapter, REG_WOW_CTRL); + trycnt = 10; + + while (!(mstatus&BIT1) && trycnt > 1) { + mstatus = rtw_read8(Adapter, REG_WOW_CTRL); + DBG_88E_LEVEL(_drv_info_, "Loop index: %d :0x%02x\n", trycnt, mstatus); + trycnt--; + rtw_msleep_os(2); + } + + Adapter->pwrctrlpriv.wowlan_wake_reason = rtw_read8(Adapter, REG_WOWLAN_WAKE_REASON); + DBG_88E_LEVEL(_drv_always_, "wowlan_wake_reason: 0x%02x\n", + Adapter->pwrctrlpriv.wowlan_wake_reason); + + /* Invoid SE0 reset signal during suspending*/ + rtw_write8(Adapter, REG_RSV_CTRL, 0x20); + rtw_write8(Adapter, REG_RSV_CTRL, 0x60); + + /* rtw_msleep_os(10); */ + break; + case WOWLAN_DISABLE: + DBG_88E_LEVEL(_drv_always_, "WOWLAN_DISABLE\n"); + trycnt = 10; + rtl8188es_set_wowlan_cmd(Adapter, 0); + mstatus = rtw_read8(Adapter, REG_WOW_CTRL); + DBG_88E_LEVEL(_drv_info_, "%s mstatus:0x%02x\n", __func__, mstatus); + + while (mstatus&BIT1 && trycnt > 1) { + mstatus = rtw_read8(Adapter, REG_WOW_CTRL); + DBG_88E_LEVEL(_drv_always_, "Loop index: %d :0x%02x\n", trycnt, mstatus); + trycnt--; + rtw_msleep_os(2); + } + + if (mstatus & BIT1) + printk("System did not release RX_DMA\n"); + else + SetFwRelatedForWoWLAN8188ES(Adapter, false); + + rtw_msleep_os(2); + if (!(Adapter->pwrctrlpriv.wowlan_wake_reason & FWDecisionDisconnect)) + rtl8188e_set_FwJoinBssReport_cmd(Adapter, 1); + break; + default: + break; + } + } + break; #endif /* CONFIG_WOWLAN */ - - case HW_VAR_TX_RPT_MAX_MACID: - { - u8 maxMacid = *val; - DBG_88E("### MacID(%d),Set Max Tx RPT MID(%d)\n",maxMacid,maxMacid+1); - rtw_write8(Adapter, REG_TX_RPT_CTRL+1, maxMacid+1); - } - break; - case HW_VAR_H2C_MEDIA_STATUS_RPT: - { - rtl8188e_set_FwMediaStatus_cmd(Adapter , (*(__le16 *)val)); - } - break; - case HW_VAR_BCN_VALID: - /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ - rtw_write8(Adapter, REG_TDECTRL+2, rtw_read8(Adapter, REG_TDECTRL+2) | BIT0); - break; - - default: - - break; + case HW_VAR_TX_RPT_MAX_MACID: + { + u8 maxMacid = *val; + DBG_88E("### MacID(%d),Set Max Tx RPT MID(%d)\n", maxMacid, maxMacid+1); + rtw_write8(Adapter, REG_TX_RPT_CTRL+1, maxMacid+1); + } + break; + case HW_VAR_H2C_MEDIA_STATUS_RPT: + rtl8188e_set_FwMediaStatus_cmd(Adapter , (*(__le16 *)val)); + break; + case HW_VAR_BCN_VALID: + /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ + rtw_write8(Adapter, REG_TDECTRL+2, rtw_read8(Adapter, REG_TDECTRL+2) | BIT0); + break; + default: + break; } - _func_exit_; } -static void GetHwReg8188EU(struct adapter * Adapter, u8 variable, u8* val) +static void GetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct odm_dm_struct *podmpriv = &pHalData->odmpriv; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct odm_dm_struct *podmpriv = &haldata->odmpriv; _func_enter_; - switch (variable) - { - case HW_VAR_BASIC_RATE: - *((u16 *)(val)) = pHalData->BasicRateSet; - case HW_VAR_TXPAUSE: - val[0] = rtw_read8(Adapter, REG_TXPAUSE); - break; - case HW_VAR_BCN_VALID: - /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ - val[0] = (BIT0 & rtw_read8(Adapter, REG_TDECTRL+2))?true:false; - break; - case HW_VAR_DM_FLAG: - val[0] = podmpriv->SupportAbility; - break; - case HW_VAR_RF_TYPE: - val[0] = pHalData->rf_type; - break; - case HW_VAR_FWLPS_RF_ON: - { - /* When we halt NIC, we should check if FW LPS is leave. */ - if (Adapter->pwrctrlpriv.rf_pwrstate == rf_off) - { - /* If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave, */ - /* because Fw is unload. */ - val[0] = true; - } + switch (variable) { + case HW_VAR_BASIC_RATE: + *((u16 *)(val)) = haldata->BasicRateSet; + case HW_VAR_TXPAUSE: + val[0] = rtw_read8(Adapter, REG_TXPAUSE); + break; + case HW_VAR_BCN_VALID: + /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ + val[0] = (BIT0 & rtw_read8(Adapter, REG_TDECTRL+2)) ? true : false; + break; + case HW_VAR_DM_FLAG: + val[0] = podmpriv->SupportAbility; + break; + case HW_VAR_RF_TYPE: + val[0] = haldata->rf_type; + break; + case HW_VAR_FWLPS_RF_ON: + { + /* When we halt NIC, we should check if FW LPS is leave. */ + if (Adapter->pwrctrlpriv.rf_pwrstate == rf_off) { + /* If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave, */ + /* because Fw is unload. */ + val[0] = true; + } else { + u32 valRCR; + valRCR = rtw_read32(Adapter, REG_RCR); + valRCR &= 0x00070000; + if (valRCR) + val[0] = false; else - { - u32 valRCR; - valRCR = rtw_read32(Adapter, REG_RCR); - valRCR &= 0x00070000; - if (valRCR) - val[0] = false; - else - val[0] = true; - } + val[0] = true; } - break; - case HW_VAR_CURRENT_ANTENNA: - val[0] = pHalData->CurAntenna; - break; - case HW_VAR_EFUSE_BYTES: /* To get EFUE total used bytes, added by Roger, 2008.12.22. */ - *((u16 *)(val)) = pHalData->EfuseUsedBytes; - break; - case HW_VAR_APFM_ON_MAC: - *val = pHalData->bMacPwrCtrlOn; - break; - case HW_VAR_CHK_HI_QUEUE_EMPTY: - *val = ((rtw_read32(Adapter, REG_HGQ_INFORMATION)&0x0000ff00)==0) ? true:false; - break; - default: - break; + } + break; + case HW_VAR_CURRENT_ANTENNA: + val[0] = haldata->CurAntenna; + break; + case HW_VAR_EFUSE_BYTES: /* To get EFUE total used bytes, added by Roger, 2008.12.22. */ + *((u16 *)(val)) = haldata->EfuseUsedBytes; + break; + case HW_VAR_APFM_ON_MAC: + *val = haldata->bMacPwrCtrlOn; + break; + case HW_VAR_CHK_HI_QUEUE_EMPTY: + *val = ((rtw_read32(Adapter, REG_HGQ_INFORMATION)&0x0000ff00) == 0) ? true : false; + break; + default: + break; } _func_exit_; } /* */ -/* Description: */ -/* Query setting of specified variable. */ +/* Description: */ +/* Query setting of specified variable. */ /* */ static u8 GetHalDefVar8188EUsb( - struct adapter * Adapter, - enum hal_def_variable eVariable, - void * pValue + struct adapter *Adapter, + enum hal_def_variable eVariable, + void *pValue ) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 bResult = _SUCCESS; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u8 bResult = _SUCCESS; switch (eVariable) { case HAL_DEF_UNDERCORATEDSMOOTHEDPWDB: { struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - struct sta_priv * pstapriv = &Adapter->stapriv; - struct sta_info * psta; + struct sta_priv *pstapriv = &Adapter->stapriv; + struct sta_info *psta; psta = rtw_get_stainfo(pstapriv, pmlmepriv->cur_network.network.MacAddress); if (psta) - { *((int *)pValue) = psta->rssi_stat.UndecoratedSmoothedPWDB; - } } break; case HAL_DEF_IS_SUPPORT_ANT_DIV: - *((u8 *)pValue) = (pHalData->AntDivCfg==0)?false:true; + *((u8 *)pValue) = (haldata->AntDivCfg == 0) ? false : true; break; case HAL_DEF_CURRENT_ANTENNA: - *(( u8*)pValue) = pHalData->CurAntenna; + *((u8 *)pValue) = haldata->CurAntenna; break; case HAL_DEF_DRVINFO_SZ: - *(( u32*)pValue) = DRVINFO_SZ; + *((u32 *)pValue) = DRVINFO_SZ; break; case HAL_DEF_MAX_RECVBUF_SZ: - *(( u32*)pValue) = MAX_RECVBUF_SZ; + *((u32 *)pValue) = MAX_RECVBUF_SZ; break; case HAL_DEF_RX_PACKET_OFFSET: - *(( u32*)pValue) = RXDESC_SIZE + DRVINFO_SZ; + *((u32 *)pValue) = RXDESC_SIZE + DRVINFO_SZ; break; case HAL_DEF_DBG_DM_FUNC: - *(( u32*)pValue) =pHalData->odmpriv.SupportAbility; + *((u32 *)pValue) = haldata->odmpriv.SupportAbility; break; case HAL_DEF_RA_DECISION_RATE: { - u8 MacID = *((u8*)pValue); - *((u8*)pValue) = ODM_RA_GetDecisionRate_8188E(&(pHalData->odmpriv), MacID); + u8 MacID = *((u8 *)pValue); + *((u8 *)pValue) = ODM_RA_GetDecisionRate_8188E(&(haldata->odmpriv), MacID); } break; case HAL_DEF_RA_SGI: { - u8 MacID = *((u8*)pValue); - *((u8*)pValue) = ODM_RA_GetShortGI_8188E(&(pHalData->odmpriv), MacID); + u8 MacID = *((u8 *)pValue); + *((u8 *)pValue) = ODM_RA_GetShortGI_8188E(&(haldata->odmpriv), MacID); } break; case HAL_DEF_PT_PWR_STATUS: { - u8 MacID = *((u8*)pValue); - *((u8*)pValue) = ODM_RA_GetHwPwrStatus_8188E(&(pHalData->odmpriv), MacID); + u8 MacID = *((u8 *)pValue); + *((u8 *)pValue) = ODM_RA_GetHwPwrStatus_8188E(&(haldata->odmpriv), MacID); } break; case HW_VAR_MAX_RX_AMPDU_FACTOR: - *(( u32*)pValue) = MAX_AMPDU_FACTOR_64K; + *((u32 *)pValue) = MAX_AMPDU_FACTOR_64K; break; - case HW_DEF_RA_INFO_DUMP: + case HW_DEF_RA_INFO_DUMP: { - u8 entry_id = *((u8*)pValue); - if (check_fwstate(&Adapter->mlmepriv, _FW_LINKED)== true) - { + u8 entry_id = *((u8 *)pValue); + if (check_fwstate(&Adapter->mlmepriv, _FW_LINKED)) { DBG_88E("============ RA status check ===================\n"); - DBG_88E("Mac_id:%d ,RateID = %d,RAUseRate = 0x%08x,RateSGI = %d, DecisionRate = 0x%02x ,PTStage = %d\n", + DBG_88E("Mac_id:%d , RateID = %d, RAUseRate = 0x%08x, RateSGI = %d, DecisionRate = 0x%02x ,PTStage = %d\n", entry_id, - pHalData->odmpriv.RAInfo[entry_id].RateID, - pHalData->odmpriv.RAInfo[entry_id].RAUseRate, - pHalData->odmpriv.RAInfo[entry_id].RateSGI, - pHalData->odmpriv.RAInfo[entry_id].DecisionRate, - pHalData->odmpriv.RAInfo[entry_id].PTStage); + haldata->odmpriv.RAInfo[entry_id].RateID, + haldata->odmpriv.RAInfo[entry_id].RAUseRate, + haldata->odmpriv.RAInfo[entry_id].RateSGI, + haldata->odmpriv.RAInfo[entry_id].DecisionRate, + haldata->odmpriv.RAInfo[entry_id].PTStage); } } break; case HW_DEF_ODM_DBG_FLAG: { - u8Byte DebugComponents = *((u32*)pValue); - struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); - printk("pDM_Odm->DebugComponents = 0x%llx\n",pDM_Odm->DebugComponents ); + u8Byte DebugComponents = *((u32 *)pValue); + struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); + pr_info("dm_ocm->DebugComponents = 0x%llx\n", dm_ocm->DebugComponents); } break; case HAL_DEF_DBG_DUMP_RXPKT: - *(( u8*)pValue) = pHalData->bDumpRxPkt; + *((u8 *)pValue) = haldata->bDumpRxPkt; break; case HAL_DEF_DBG_DUMP_TXPKT: - *(( u8*)pValue) = pHalData->bDumpTxPkt; + *((u8 *)pValue) = haldata->bDumpTxPkt; break; default: bResult = _FAIL; @@ -2874,335 +2491,281 @@ GetHalDefVar8188EUsb( return bResult; } - - - /* */ -/* Description: */ -/* Change default setting of specified variable. */ +/* Description: */ +/* Change default setting of specified variable. */ /* */ -static u8 SetHalDefVar8188EUsb( - struct adapter * Adapter, - enum hal_def_variable eVariable, - void * pValue - ) +static u8 SetHalDefVar8188EUsb(struct adapter *Adapter, enum hal_def_variable eVariable, void *pValue) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 bResult = _SUCCESS; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u8 bResult = _SUCCESS; - switch (eVariable) - { - case HAL_DEF_DBG_DM_FUNC: - { - u8 dm_func = *(( u8*)pValue); - struct dm_priv *pdmpriv = &pHalData->dmpriv; - struct odm_dm_struct *podmpriv = &pHalData->odmpriv; + switch (eVariable) { + case HAL_DEF_DBG_DM_FUNC: + { + u8 dm_func = *((u8 *)pValue); + struct dm_priv *pdmpriv = &haldata->dmpriv; + struct odm_dm_struct *podmpriv = &haldata->odmpriv; - if (dm_func == 0){ /* disable all dynamic func */ - podmpriv->SupportAbility = DYNAMIC_FUNC_DISABLE; - DBG_88E("==> Disable all dynamic function...\n"); - } - else if (dm_func == 1){/* disable DIG */ - podmpriv->SupportAbility &= (~DYNAMIC_BB_DIG); - DBG_88E("==> Disable DIG...\n"); - } - else if (dm_func == 2){/* disable High power */ - podmpriv->SupportAbility &= (~DYNAMIC_BB_DYNAMIC_TXPWR); - } - else if (dm_func == 3){/* disable tx power tracking */ - podmpriv->SupportAbility &= (~DYNAMIC_RF_CALIBRATION); - DBG_88E("==> Disable tx power tracking...\n"); - } - else if (dm_func == 5){/* disable antenna diversity */ - podmpriv->SupportAbility &= (~DYNAMIC_BB_ANT_DIV); - } - else if (dm_func == 6){/* turn on all dynamic func */ - if (!(podmpriv->SupportAbility & DYNAMIC_BB_DIG)) - { - struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; - pDigTable->CurIGValue= rtw_read8(Adapter,0xc50); - } - podmpriv->SupportAbility = DYNAMIC_ALL_FUNC_ENABLE; - DBG_88E("==> Turn on all dynamic function...\n"); + if (dm_func == 0) { /* disable all dynamic func */ + podmpriv->SupportAbility = DYNAMIC_FUNC_DISABLE; + DBG_88E("==> Disable all dynamic function...\n"); + } else if (dm_func == 1) {/* disable DIG */ + podmpriv->SupportAbility &= (~DYNAMIC_BB_DIG); + DBG_88E("==> Disable DIG...\n"); + } else if (dm_func == 2) {/* disable High power */ + podmpriv->SupportAbility &= (~DYNAMIC_BB_DYNAMIC_TXPWR); + } else if (dm_func == 3) {/* disable tx power tracking */ + podmpriv->SupportAbility &= (~DYNAMIC_RF_CALIBRATION); + DBG_88E("==> Disable tx power tracking...\n"); + } else if (dm_func == 5) {/* disable antenna diversity */ + podmpriv->SupportAbility &= (~DYNAMIC_BB_ANT_DIV); + } else if (dm_func == 6) {/* turn on all dynamic func */ + if (!(podmpriv->SupportAbility & DYNAMIC_BB_DIG)) { + struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; + pDigTable->CurIGValue = rtw_read8(Adapter, 0xc50); } + podmpriv->SupportAbility = DYNAMIC_ALL_FUNC_ENABLE; + DBG_88E("==> Turn on all dynamic function...\n"); } - break; - case HAL_DEF_DBG_DUMP_RXPKT: - pHalData->bDumpRxPkt = *(( u8*)pValue); - break; - case HAL_DEF_DBG_DUMP_TXPKT: - pHalData->bDumpTxPkt = *(( u8*)pValue); - break; - case HW_DEF_FA_CNT_DUMP: - { - u8 bRSSIDump = *((u8*)pValue); - struct odm_dm_struct * pDM_Odm = &(pHalData->odmpriv); - if (bRSSIDump) - pDM_Odm->DebugComponents = ODM_COMP_DIG|ODM_COMP_FA_CNT ; - else - pDM_Odm->DebugComponents = 0; - - } - break; - case HW_DEF_ODM_DBG_FLAG: - { - u8Byte DebugComponents = *((u8Byte*)pValue); - struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); - pDM_Odm->DebugComponents = DebugComponents; - } - break; - default: - bResult = _FAIL; - break; + } + break; + case HAL_DEF_DBG_DUMP_RXPKT: + haldata->bDumpRxPkt = *((u8 *)pValue); + break; + case HAL_DEF_DBG_DUMP_TXPKT: + haldata->bDumpTxPkt = *((u8 *)pValue); + break; + case HW_DEF_FA_CNT_DUMP: + { + u8 bRSSIDump = *((u8 *)pValue); + struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); + if (bRSSIDump) + dm_ocm->DebugComponents = ODM_COMP_DIG|ODM_COMP_FA_CNT ; + else + dm_ocm->DebugComponents = 0; + } + break; + case HW_DEF_ODM_DBG_FLAG: + { + u8Byte DebugComponents = *((u8Byte *)pValue); + struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); + dm_ocm->DebugComponents = DebugComponents; + } + break; + default: + bResult = _FAIL; + break; } return bResult; } -static void _update_response_rate(struct adapter *padapter,unsigned int mask) +static void _update_response_rate(struct adapter *adapt, unsigned int mask) { - u8 RateIndex = 0; + u8 RateIndex = 0; /* Set RRSR rate table. */ - rtw_write8(padapter, REG_RRSR, mask&0xff); - rtw_write8(padapter,REG_RRSR+1, (mask>>8)&0xff); + rtw_write8(adapt, REG_RRSR, mask&0xff); + rtw_write8(adapt, REG_RRSR+1, (mask>>8)&0xff); /* Set RTS initial rate */ - while (mask > 0x1) - { - mask = (mask>> 1); + while (mask > 0x1) { + mask = (mask >> 1); RateIndex++; } - rtw_write8(padapter, REG_INIRTS_RATE_SEL, RateIndex); + rtw_write8(adapt, REG_INIRTS_RATE_SEL, RateIndex); } -static void UpdateHalRAMask8188EUsb(struct adapter * padapter, u32 mac_id, u8 rssi_level) +static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level) { - u8 init_rate=0; - u8 networkType, raid; - u32 mask,rate_bitmap; - u8 shortGIrate = false; + u8 init_rate = 0; + u8 networkType, raid; + u32 mask, rate_bitmap; + u8 shortGIrate = false; int supportRateNum = 0; struct sta_info *psta; - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); if (mac_id >= NUM_STA) /* CAM_SIZE */ return; - psta = pmlmeinfo->FW_sta_info[mac_id].psta; if (psta == NULL) return; + switch (mac_id) { + case 0:/* for infra mode */ + supportRateNum = rtw_get_rateset_len(cur_network->SupportedRates); + networkType = judge_network_type(adapt, cur_network->SupportedRates, supportRateNum) & 0xf; + raid = networktype_to_raid(networkType); + mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); + mask |= (pmlmeinfo->HT_enable) ? update_MSC_rate(&(pmlmeinfo->HT_caps)) : 0; + if (support_short_GI(adapt, &(pmlmeinfo->HT_caps))) + shortGIrate = true; + break; + case 1:/* for broadcast/multicast */ + supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); + if (pmlmeext->cur_wireless_mode & WIRELESS_11B) + networkType = WIRELESS_11B; + else + networkType = WIRELESS_11G; + raid = networktype_to_raid(networkType); + mask = update_basic_rate(cur_network->SupportedRates, supportRateNum); + break; + default: /* for each sta in IBSS */ + supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); + networkType = judge_network_type(adapt, pmlmeinfo->FW_sta_info[mac_id].SupportedRates, supportRateNum) & 0xf; + raid = networktype_to_raid(networkType); + mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); - switch (mac_id) - { - case 0:/* for infra mode */ - supportRateNum = rtw_get_rateset_len(cur_network->SupportedRates); - networkType = judge_network_type(padapter, cur_network->SupportedRates, supportRateNum) & 0xf; - raid = networktype_to_raid(networkType); - - mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); - mask |= (pmlmeinfo->HT_enable)? update_MSC_rate(&(pmlmeinfo->HT_caps)): 0; - - - if (support_short_GI(padapter, &(pmlmeinfo->HT_caps))) - { - shortGIrate = true; - } - - break; - - case 1:/* for broadcast/multicast */ - supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); - if (pmlmeext->cur_wireless_mode & WIRELESS_11B) - networkType = WIRELESS_11B; - else - networkType = WIRELESS_11G; - raid = networktype_to_raid(networkType); - mask = update_basic_rate(cur_network->SupportedRates, supportRateNum); - - - break; - - default: /* for each sta in IBSS */ - supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); - networkType = judge_network_type(padapter, pmlmeinfo->FW_sta_info[mac_id].SupportedRates, supportRateNum) & 0xf; - raid = networktype_to_raid(networkType); - mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); - - /* todo: support HT in IBSS */ - - break; + /* todo: support HT in IBSS */ + break; } rate_bitmap = 0x0fffffff; - rate_bitmap = ODM_Get_Rate_Bitmap(&pHalData->odmpriv,mac_id,mask,rssi_level); + rate_bitmap = ODM_Get_Rate_Bitmap(&haldata->odmpriv, mac_id, mask, rssi_level); DBG_88E("%s => mac_id:%d, networkType:0x%02x, mask:0x%08x\n\t ==> rssi_level:%d, rate_bitmap:0x%08x\n", - __func__,mac_id,networkType,mask,rssi_level,rate_bitmap); + __func__, mac_id, networkType, mask, rssi_level, rate_bitmap); mask &= rate_bitmap; init_rate = get_highest_rate_idx(mask)&0x3f; - if (pHalData->fw_ractrl == true) - { - u8 arg = 0; - - arg = mac_id&0x1f;/* MACID */ + if (haldata->fw_ractrl) { + u8 arg; + arg = mac_id & 0x1f;/* MACID */ arg |= BIT(7); - - if (shortGIrate==true) + if (shortGIrate) arg |= BIT(5); - mask |= ((raid<<28)&0xf0000000); + mask |= ((raid << 28) & 0xf0000000); DBG_88E("update raid entry, mask=0x%x, arg=0x%x\n", mask, arg); - psta->ra_mask=mask; - mask |= ((raid<<28)&0xf0000000); + psta->ra_mask = mask; + mask |= ((raid << 28) & 0xf0000000); /* to do ,for 8188E-SMIC */ - /* - *(pu4Byte)&RateMask=EF4Byte((ratr_bitmap&0x0fffffff) | (ratr_index<<28)); - RateMask[4] = macId | (bShortGI?0x20:0x00) | 0x80; - */ - rtl8188e_set_raid_cmd(padapter, mask); - - } - else - { - ODM_RA_UpdateRateInfo_8188E( - &(pHalData->odmpriv), + rtl8188e_set_raid_cmd(adapt, mask); + } else { + ODM_RA_UpdateRateInfo_8188E(&(haldata->odmpriv), mac_id, raid, mask, shortGIrate ); } - - /* set ra_id */ psta->raid = raid; psta->init_rate = init_rate; - - } -static void SetBeaconRelatedRegisters8188EUsb(struct adapter * padapter) +static void SetBeaconRelatedRegisters8188EUsb(struct adapter *adapt) { - u32 value32; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + u32 value32; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u32 bcn_ctrl_reg = REG_BCN_CTRL; /* reset TSF, enable update TSF, correcting TSF On Beacon */ /* BCN interval */ - rtw_write16(padapter, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval); - rtw_write8(padapter, REG_ATIMWND, 0x02);/* 2ms */ + rtw_write16(adapt, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval); + rtw_write8(adapt, REG_ATIMWND, 0x02);/* 2ms */ - _InitBeaconParameters(padapter); + _InitBeaconParameters(adapt); - rtw_write8(padapter, REG_SLOT, 0x09); + rtw_write8(adapt, REG_SLOT, 0x09); - value32 =rtw_read32(padapter, REG_TCR); + value32 = rtw_read32(adapt, REG_TCR); value32 &= ~TSFRST; - rtw_write32(padapter, REG_TCR, value32); + rtw_write32(adapt, REG_TCR, value32); value32 |= TSFRST; - rtw_write32(padapter, REG_TCR, value32); + rtw_write32(adapt, REG_TCR, value32); /* NOTE: Fix test chip's bug (about contention windows's randomness) */ - rtw_write8(padapter, REG_RXTSF_OFFSET_CCK, 0x50); - rtw_write8(padapter, REG_RXTSF_OFFSET_OFDM, 0x50); + rtw_write8(adapt, REG_RXTSF_OFFSET_CCK, 0x50); + rtw_write8(adapt, REG_RXTSF_OFFSET_OFDM, 0x50); - _BeaconFunctionEnable(padapter, true, true); + _BeaconFunctionEnable(adapt, true, true); - ResumeTxBeacon(padapter); - - - - - rtw_write8(padapter, bcn_ctrl_reg, rtw_read8(padapter, bcn_ctrl_reg)|BIT(1)); + ResumeTxBeacon(adapt); + rtw_write8(adapt, bcn_ctrl_reg, rtw_read8(adapt, bcn_ctrl_reg)|BIT(1)); } -static void rtl8188eu_init_default_value(struct adapter * padapter) +static void rtl8188eu_init_default_value(struct adapter *adapt) { - struct hal_data_8188e *pHalData; + struct hal_data_8188e *haldata; struct pwrctrl_priv *pwrctrlpriv; u8 i; - pHalData = GET_HAL_DATA(padapter); - pwrctrlpriv = &padapter->pwrctrlpriv; - + haldata = GET_HAL_DATA(adapt); + pwrctrlpriv = &adapt->pwrctrlpriv; /* init default value */ - pHalData->fw_ractrl = false; + haldata->fw_ractrl = false; if (!pwrctrlpriv->bkeepfwalive) - pHalData->LastHMEBoxNum = 0; + haldata->LastHMEBoxNum = 0; /* init dm default value */ - pHalData->odmpriv.RFCalibrateInfo.bIQKInitialized = false; - pHalData->odmpriv.RFCalibrateInfo.TM_Trigger = 0;/* for IQK */ - pHalData->pwrGroupCnt = 0; - pHalData->PGMaxGroup= 13; - pHalData->odmpriv.RFCalibrateInfo.ThermalValue_HP_index = 0; + haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = false; + haldata->odmpriv.RFCalibrateInfo.TM_Trigger = 0;/* for IQK */ + haldata->pwrGroupCnt = 0; + haldata->PGMaxGroup = 13; + haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP_index = 0; for (i = 0; i < HP_THERMAL_NUM; i++) - pHalData->odmpriv.RFCalibrateInfo.ThermalValue_HP[i] = 0; + haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP[i] = 0; } -static u8 rtl8188eu_ps_func(struct adapter * Adapter,enum hal_intf_ps_func efunc_id, u8 *val) +static u8 rtl8188eu_ps_func(struct adapter *Adapter, enum hal_intf_ps_func efunc_id, u8 *val) { u8 bResult = true; return bResult; } -void rtl8188eu_set_hal_ops(struct adapter * padapter) +void rtl8188eu_set_hal_ops(struct adapter *adapt) { - struct hal_ops *pHalFunc = &padapter->HalFunc; + struct hal_ops *halfunc = &adapt->HalFunc; _func_enter_; - padapter->HalData = rtw_zmalloc(sizeof(struct hal_data_8188e)); - if (padapter->HalData == NULL){ + adapt->HalData = rtw_zmalloc(sizeof(struct hal_data_8188e)); + if (adapt->HalData == NULL) DBG_88E("cant not alloc memory for HAL DATA\n"); - } - padapter->hal_data_sz = sizeof(struct hal_data_8188e); + adapt->hal_data_sz = sizeof(struct hal_data_8188e); - pHalFunc->hal_power_on = rtl8188eu_InitPowerOn; - pHalFunc->hal_init = &rtl8188eu_hal_init; - pHalFunc->hal_deinit = &rtl8188eu_hal_deinit; + halfunc->hal_power_on = rtl8188eu_InitPowerOn; + halfunc->hal_init = &rtl8188eu_hal_init; + halfunc->hal_deinit = &rtl8188eu_hal_deinit; + halfunc->inirp_init = &rtl8188eu_inirp_init; + halfunc->inirp_deinit = &rtl8188eu_inirp_deinit; - pHalFunc->inirp_init = &rtl8188eu_inirp_init; - pHalFunc->inirp_deinit = &rtl8188eu_inirp_deinit; + halfunc->init_xmit_priv = &rtl8188eu_init_xmit_priv; + halfunc->free_xmit_priv = &rtl8188eu_free_xmit_priv; - pHalFunc->init_xmit_priv = &rtl8188eu_init_xmit_priv; - pHalFunc->free_xmit_priv = &rtl8188eu_free_xmit_priv; + halfunc->init_recv_priv = &rtl8188eu_init_recv_priv; + halfunc->free_recv_priv = &rtl8188eu_free_recv_priv; + halfunc->InitSwLeds = &rtl8188eu_InitSwLeds; + halfunc->DeInitSwLeds = &rtl8188eu_DeInitSwLeds; - pHalFunc->init_recv_priv = &rtl8188eu_init_recv_priv; - pHalFunc->free_recv_priv = &rtl8188eu_free_recv_priv; - pHalFunc->InitSwLeds = &rtl8188eu_InitSwLeds; - pHalFunc->DeInitSwLeds = &rtl8188eu_DeInitSwLeds; + halfunc->init_default_value = &rtl8188eu_init_default_value; + halfunc->intf_chip_configure = &rtl8188eu_interface_configure; + halfunc->read_adapter_info = &ReadAdapterInfo8188EU; - pHalFunc->init_default_value = &rtl8188eu_init_default_value; - pHalFunc->intf_chip_configure = &rtl8188eu_interface_configure; - pHalFunc->read_adapter_info = &ReadAdapterInfo8188EU; + halfunc->SetHwRegHandler = &SetHwReg8188EU; + halfunc->GetHwRegHandler = &GetHwReg8188EU; + halfunc->GetHalDefVarHandler = &GetHalDefVar8188EUsb; + halfunc->SetHalDefVarHandler = &SetHalDefVar8188EUsb; - pHalFunc->SetHwRegHandler = &SetHwReg8188EU; - pHalFunc->GetHwRegHandler = &GetHwReg8188EU; - pHalFunc->GetHalDefVarHandler = &GetHalDefVar8188EUsb; - pHalFunc->SetHalDefVarHandler = &SetHalDefVar8188EUsb; + halfunc->UpdateRAMaskHandler = &UpdateHalRAMask8188EUsb; + halfunc->SetBeaconRelatedRegistersHandler = &SetBeaconRelatedRegisters8188EUsb; - pHalFunc->UpdateRAMaskHandler = &UpdateHalRAMask8188EUsb; - pHalFunc->SetBeaconRelatedRegistersHandler = &SetBeaconRelatedRegisters8188EUsb; + halfunc->hal_xmit = &rtl8188eu_hal_xmit; + halfunc->mgnt_xmit = &rtl8188eu_mgnt_xmit; + halfunc->interface_ps_func = &rtl8188eu_ps_func; - pHalFunc->hal_xmit = &rtl8188eu_hal_xmit; - pHalFunc->mgnt_xmit = &rtl8188eu_mgnt_xmit; - - pHalFunc->interface_ps_func = &rtl8188eu_ps_func; - - rtl8188e_set_hal_ops(pHalFunc); + rtl8188e_set_hal_ops(halfunc); _func_exit_; - } diff --git a/hal/usb_ops_linux.c b/hal/usb_ops_linux.c index 4cf038a..e69e7c6 100644 --- a/hal/usb_ops_linux.c +++ b/hal/usb_ops_linux.c @@ -29,106 +29,93 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) { - struct adapter *padapter = pintfhdl->padapter; - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); - struct usb_device *udev = pdvobjpriv->pusbdev; + struct adapter *adapt = pintfhdl->padapter; + struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); + struct usb_device *udev = dvobjpriv->pusbdev; unsigned int pipe; int status = 0; - u32 tmp_buflen=0; + u32 tmp_buflen = 0; u8 reqtype; u8 *pIo_buf; int vendorreq_times = 0; u8 tmp_buf[MAX_USB_IO_CTL_SIZE]; - if ((padapter->bSurpriseRemoved) ||(padapter->pwrctrlpriv.pnp_bstop_trx)){ - RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usbctrl_vendorreq:(padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + if ((adapt->bSurpriseRemoved) || (adapt->pwrctrlpriv.pnp_bstop_trx)) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usbctrl_vendorreq:(adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); status = -EPERM; goto exit; } - if (len>MAX_VENDOR_REQ_CMD_SIZE){ - DBG_88E( "[%s] Buffer len error ,vendor request failed\n", __func__ ); + if (len > MAX_VENDOR_REQ_CMD_SIZE) { + DBG_88E("[%s] Buffer len error ,vendor request failed\n", __func__); status = -EINVAL; goto exit; } - _enter_critical_mutex(&pdvobjpriv->usb_vendor_req_mutex, NULL); + _enter_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL); /* Acquire IO memory for vendorreq */ - pIo_buf = pdvobjpriv->usb_vendor_req_buf; + pIo_buf = dvobjpriv->usb_vendor_req_buf; - if ( pIo_buf== NULL) { - DBG_88E( "[%s] pIo_buf == NULL\n", __func__ ); + if (pIo_buf == NULL) { + DBG_88E("[%s] pIo_buf == NULL\n", __func__); status = -ENOMEM; goto release_mutex; } - while (++vendorreq_times<= MAX_USBCTRL_VENDORREQ_TIMES) - { + while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { _rtw_memset(pIo_buf, 0, len); - if (requesttype == 0x01) - { + if (requesttype == 0x01) { pipe = usb_rcvctrlpipe(udev, 0);/* read_in */ reqtype = REALTEK_USB_VENQT_READ; - } - else - { + } else { pipe = usb_sndctrlpipe(udev, 0);/* write_out */ reqtype = REALTEK_USB_VENQT_WRITE; - _rtw_memcpy( pIo_buf, pdata, len); + _rtw_memcpy(pIo_buf, pdata, len); } status = rtw_usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); - if ( status == len) /* Success this control transfer. */ - { - rtw_reset_continual_urb_error(pdvobjpriv); - if ( requesttype == 0x01 ) - { /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */ - _rtw_memcpy( pdata, pIo_buf, len ); - } - } - else { /* error cases */ - DBG_88E("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n" - , value,(requesttype == 0x01)?"read":"write" , len, status, *(u32*)pdata, vendorreq_times); + if (status == len) { /* Success this control transfer. */ + rtw_reset_continual_urb_error(dvobjpriv); + if (requesttype == 0x01) + _rtw_memcpy(pdata, pIo_buf, len); + } else { /* error cases */ + DBG_88E("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n", + value, (requesttype == 0x01) ? "read" : "write", + len, status, *(u32 *)pdata, vendorreq_times); if (status < 0) { - if (status == (-ESHUTDOWN) || status == -ENODEV ) - { - padapter->bSurpriseRemoved = true; + if (status == (-ESHUTDOWN) || status == -ENODEV) { + adapt->bSurpriseRemoved = true; } else { - { - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - pHalData->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL; - } + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + haldata->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL; } - } - else /* status != len && status >= 0 */ - { + } else { /* status != len && status >= 0 */ if (status > 0) { - if ( requesttype == 0x01 ) - { /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */ - _rtw_memcpy( pdata, pIo_buf, len ); + if (requesttype == 0x01) { + /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */ + _rtw_memcpy(pdata, pIo_buf, len); } } } - if (rtw_inc_and_chk_continual_urb_error(pdvobjpriv) == true ){ - padapter->bSurpriseRemoved = true; + if (rtw_inc_and_chk_continual_urb_error(dvobjpriv)) { + adapt->bSurpriseRemoved = true; break; } } /* firmware download is checksumed, don't retry */ - if ( (value >= FW_8188E_START_ADDRESS && value <= FW_8188E_END_ADDRESS) || status == len ) + if ((value >= FW_8188E_START_ADDRESS && value <= FW_8188E_END_ADDRESS) || status == len) break; - } release_mutex: - _exit_critical_mutex(&pdvobjpriv->usb_vendor_req_mutex, NULL); + _exit_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL); exit: return status; } @@ -140,7 +127,7 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) u16 wvalue; u16 index; u16 len; - u8 data=0; + u8 data = 0; _func_enter_; @@ -216,22 +203,15 @@ static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) int ret; _func_enter_; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); len = 1; - data = val; - - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - + ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); _func_exit_; - return ret; - } static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) @@ -282,7 +262,7 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) len = 4; data = cpu_to_le32(val); - ret =usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); _func_exit_; @@ -296,7 +276,7 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata u16 wvalue; u16 index; u16 len; - u8 buf[VENDOR_CMD_MAX_DATA_LEN]={0}; + u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; int ret; _func_enter_; @@ -307,34 +287,32 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata wvalue = (u16)(addr&0x0000ffff); len = length; - _rtw_memcpy(buf, pdata, len ); + _rtw_memcpy(buf, pdata, len); ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype); _func_exit_; return ret; - } -static void interrupt_handler_8188eu(struct adapter *padapter,u16 pkt_len,u8 *pbuf) +static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf) { - struct hal_data_8188e *pHalData=GET_HAL_DATA(padapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); struct reportpwrstate_parm pwr_rpt; - if ( pkt_len != INTERRUPT_MSG_FORMAT_LEN ) - { + if (pkt_len != INTERRUPT_MSG_FORMAT_LEN) { DBG_88E("%s Invalid interrupt content length (%d)!\n", __func__, pkt_len); - return ; + return; } /* HISR */ - _rtw_memcpy(&(pHalData->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4); - _rtw_memcpy(&(pHalData->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4); + _rtw_memcpy(&(haldata->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4); + _rtw_memcpy(&(haldata->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4); /* C2H Event */ - if (pbuf[0]!= 0) - _rtw_memcpy(&(pHalData->C2hArray[0]), &(pbuf[USB_INTR_CONTENT_C2H_OFFSET]), 16); + if (pbuf[0] != 0) + _rtw_memcpy(&(haldata->C2hArray[0]), &(pbuf[USB_INTR_CONTENT_C2H_OFFSET]), 16); } static s32 pre_recv_entry(union recv_frame *precvframe, struct recv_stat *prxstat, struct phy_stat *pphy_status) @@ -342,7 +320,7 @@ static s32 pre_recv_entry(union recv_frame *precvframe, struct recv_stat *prxsta return _SUCCESS; } -static int recvbuf2recvframe(struct adapter *padapter, struct sk_buff *pskb) +static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) { u8 *pbuf; u8 shift_sz = 0; @@ -354,17 +332,17 @@ static int recvbuf2recvframe(struct adapter *padapter, struct sk_buff *pskb) struct sk_buff *pkt_copy = NULL; union recv_frame *precvframe = NULL; struct rx_pkt_attrib *pattrib = NULL; - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct recv_priv *precvpriv = &padapter->recvpriv; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct recv_priv *precvpriv = &adapt->recvpriv; struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue; transfer_len = (s32)pskb->len; pbuf = pskb->data; prxstat = (struct recv_stat *)pbuf; - pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16) & 0xff; + pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; - do{ + do { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recvbuf2recvframe: rxdesc=offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x\n", prxstat->rxdw0, prxstat->rxdw1, prxstat->rxdw2, prxstat->rxdw4)); @@ -372,121 +350,104 @@ static int recvbuf2recvframe(struct adapter *padapter, struct sk_buff *pskb) prxstat = (struct recv_stat *)pbuf; precvframe = rtw_alloc_recvframe(pfree_recv_queue); - if (precvframe==NULL) - { - RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,("recvbuf2recvframe: precvframe==NULL\n")); + if (precvframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: precvframe==NULL\n")); DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __func__, __LINE__); goto _exit_recvbuf2recvframe; } _rtw_init_listhead(&precvframe->u.hdr.list); precvframe->u.hdr.precvbuf = NULL; /* can't access the precvbuf for new arch. */ - precvframe->u.hdr.len=0; + precvframe->u.hdr.len = 0; update_recvframe_attrib_88e(precvframe, prxstat); pattrib = &precvframe->u.hdr.attrib; - if ((pattrib->crc_err) || (pattrib->icv_err)) - { + if ((pattrib->crc_err) || (pattrib->icv_err)) { DBG_88E("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __func__, pattrib->crc_err, pattrib->icv_err); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } - if ( (pattrib->physt) && (pattrib->pkt_rpt_type == NORMAL_RX)) - { + if ((pattrib->physt) && (pattrib->pkt_rpt_type == NORMAL_RX)) pphy_status = (struct phy_stat *)(pbuf + RXDESC_OFFSET); - } pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; - if ((pattrib->pkt_len<=0) || (pkt_offset>transfer_len)) - { - RT_TRACE(_module_rtl871x_recv_c_,_drv_info_,("recvbuf2recvframe: pkt_len<=0\n")); + if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recvbuf2recvframe: pkt_len<=0\n")); DBG_88E("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfoer_len\n", __func__, __LINE__); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } - /* Modified by Albert 20101213 */ - /* For 8 bytes IP header alignment. */ - if (pattrib->qos) /* Qos data, wireless lan header length is 26 */ - { + /* Modified by Albert 20101213 */ + /* For 8 bytes IP header alignment. */ + if (pattrib->qos) /* Qos data, wireless lan header length is 26 */ shift_sz = 6; - } else - { shift_sz = 0; - } skb_len = pattrib->pkt_len; /* for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet. */ /* modify alloc_sz for recvive crc error packet by thomas 2011-06-02 */ - if ((pattrib->mfrag == 1)&&(pattrib->frag_num == 0)){ + if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { if (skb_len <= 1650) alloc_sz = 1664; else alloc_sz = skb_len + 14; - } - else { + } else { alloc_sz = skb_len; - /* 6 is for IP header 8 bytes alignment in QoS packet case. */ - /* 8 is for skb->data 4 bytes alignment. */ + /* 6 is for IP header 8 bytes alignment in QoS packet case. */ + /* 8 is for skb->data 4 bytes alignment. */ alloc_sz += 14; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) /* www.mail-archive.com/netdev@vger.kernel.org/msg17214.html */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)) pkt_copy = dev_alloc_skb(alloc_sz); #else - pkt_copy = netdev_alloc_skb(padapter->pnetdev, alloc_sz); + pkt_copy = netdev_alloc_skb(adapt->pnetdev, alloc_sz); #endif - if (pkt_copy) - { - pkt_copy->dev = padapter->pnetdev; + if (pkt_copy) { + pkt_copy->dev = adapt->pnetdev; precvframe->u.hdr.pkt = pkt_copy; precvframe->u.hdr.rx_head = pkt_copy->data; precvframe->u.hdr.rx_end = pkt_copy->data + alloc_sz; - skb_reserve( pkt_copy, 8 - ((size_t)( pkt_copy->data ) & 7 ));/* force pkt_copy->data at 8-byte alignment address */ - skb_reserve( pkt_copy, shift_sz );/* force ip_hdr at 8-byte alignment address according to shift_sz. */ + skb_reserve(pkt_copy, 8 - ((size_t)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */ + skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */ _rtw_memcpy(pkt_copy->data, (pbuf + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len); - precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail = pkt_copy->data; - } - else - { - if ((pattrib->mfrag == 1)&&(pattrib->frag_num == 0)) - { + precvframe->u.hdr.rx_tail = pkt_copy->data; + precvframe->u.hdr.rx_data = pkt_copy->data; + } else { + if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { DBG_88E("recvbuf2recvframe: alloc_skb fail , drop frag frame\n"); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } - precvframe->u.hdr.pkt = skb_clone(pskb, GFP_ATOMIC); - if (precvframe->u.hdr.pkt) - { - precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail - = pbuf+ pattrib->drvinfo_sz + RXDESC_SIZE; - precvframe->u.hdr.rx_end = pbuf +pattrib->drvinfo_sz + RXDESC_SIZE+ alloc_sz; - } - else - { + if (precvframe->u.hdr.pkt) { + precvframe->u.hdr.rx_tail = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE; + precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_tail; + precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail; + precvframe->u.hdr.rx_end = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE + alloc_sz; + } else { DBG_88E("recvbuf2recvframe: skb_clone fail\n"); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } - } recvframe_put(precvframe, skb_len); - switch (pHalData->UsbRxAggMode) { + switch (haldata->UsbRxAggMode) { case USB_RX_AGG_DMA: case USB_RX_AGG_MIX: pkt_offset = (u16)_RND128(pkt_offset); break; - case USB_RX_AGG_USB: + case USB_RX_AGG_USB: pkt_offset = (u16)_RND4(pkt_offset); break; case USB_RX_AGG_DISABLE: @@ -495,26 +456,26 @@ static int recvbuf2recvframe(struct adapter *padapter, struct sk_buff *pskb) } if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ if (pattrib->physt) - update_recvframe_phyinfo_88e(precvframe, (struct phy_stat*)pphy_status); + update_recvframe_phyinfo_88e(precvframe, (struct phy_stat *)pphy_status); if (rtw_recv_entry(precvframe) != _SUCCESS) { - RT_TRACE(_module_rtl871x_recv_c_,_drv_err_, + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS\n")); } } else { /* enqueue recvframe to txrtp queue */ if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX-TXRPT ack for xmit mgmt frames. */ - handle_txrpt_ccx_88e(padapter, precvframe->u.hdr.rx_data); + handle_txrpt_ccx_88e(adapt, precvframe->u.hdr.rx_data); } else if (pattrib->pkt_rpt_type == TX_REPORT2) { ODM_RA_TxRPT2Handle_8188E( - &pHalData->odmpriv, + &haldata->odmpriv, precvframe->u.hdr.rx_data, pattrib->pkt_len, pattrib->MacIDValidEntry[0], pattrib->MacIDValidEntry[1] ); } else if (pattrib->pkt_rpt_type == HIS_REPORT) { - interrupt_handler_8188eu(padapter,pattrib->pkt_len,precvframe->u.hdr.rx_data); + interrupt_handler_8188eu(adapt, pattrib->pkt_len, precvframe->u.hdr.rx_data); } rtw_free_recvframe(precvframe, pfree_recv_queue); } @@ -537,16 +498,16 @@ _exit_recvbuf2recvframe: void rtl8188eu_recv_tasklet(void *priv) { struct sk_buff *pskb; - struct adapter *padapter = (struct adapter*)priv; - struct recv_priv *precvpriv = &padapter->recvpriv; + struct adapter *adapt = (struct adapter *)priv; + struct recv_priv *precvpriv = &adapt->recvpriv; while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { - if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) { + if ((adapt->bDriverStopped) || (adapt->bSurpriseRemoved)) { DBG_88E("recv_tasklet => bDriverStopped or bSurpriseRemoved\n"); dev_kfree_skb_any(pskb); break; } - recvbuf2recvframe(padapter, pskb); + recvbuf2recvframe(adapt, pskb); skb_reset_tail_pointer(pskb); pskb->len = 0; skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); @@ -555,75 +516,75 @@ void rtl8188eu_recv_tasklet(void *priv) static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) { - unsigned long irqL; + unsigned long irql; uint isevt, *pbuf; struct recv_buf *precvbuf = (struct recv_buf *)purb->context; - struct adapter *padapter =(struct adapter *)precvbuf->adapter; - struct recv_priv *precvpriv = &padapter->recvpriv; + struct adapter *adapt = (struct adapter *)precvbuf->adapter; + struct recv_priv *precvpriv = &adapt->recvpriv; - RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete!!!\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete!!!\n")); - precvpriv->rx_pending_cnt --; + precvpriv->rx_pending_cnt--; - if (padapter->bSurpriseRemoved || padapter->bDriverStopped || padapter->bReadPortCancel) { + if (adapt->bSurpriseRemoved || adapt->bDriverStopped || adapt->bReadPortCancel) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", - padapter->bDriverStopped, padapter->bSurpriseRemoved)); + adapt->bDriverStopped, adapt->bSurpriseRemoved)); precvbuf->reuse = true; DBG_88E("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n", - __func__, padapter->bDriverStopped, - padapter->bSurpriseRemoved, padapter->bReadPortCancel); + __func__, adapt->bDriverStopped, + adapt->bSurpriseRemoved, adapt->bReadPortCancel); goto exit; } - if (purb->status==0) {/* SUCCESS */ + if (purb->status == 0) { /* SUCCESS */ if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n")); precvbuf->reuse = true; - rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); DBG_88E("%s()-%d: RX Warning!\n", __func__, __LINE__); } else { - rtw_reset_continual_urb_error(adapter_to_dvobj(padapter)); + rtw_reset_continual_urb_error(adapter_to_dvobj(adapt)); precvbuf->transfer_len = purb->actual_length; skb_put(precvbuf->pskb, purb->actual_length); skb_queue_tail(&precvpriv->rx_skb_queue, precvbuf->pskb); - if (skb_queue_len(&precvpriv->rx_skb_queue)<=1) + if (skb_queue_len(&precvpriv->rx_skb_queue) <= 1) tasklet_schedule(&precvpriv->recv_tasklet); precvbuf->pskb = NULL; precvbuf->reuse = false; - rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); } } else { - RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete : purb->status(%d) != 0\n", purb->status)); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete : purb->status(%d) != 0\n", purb->status)); DBG_88E("###=> usb_read_port_complete => urb status(%d)\n", purb->status); - if (rtw_inc_and_chk_continual_urb_error(adapter_to_dvobj(padapter)) == true ) - padapter->bSurpriseRemoved = true; + if (rtw_inc_and_chk_continual_urb_error(adapter_to_dvobj(adapt))) + adapt->bSurpriseRemoved = true; switch (purb->status) { case -EINVAL: case -EPIPE: case -ENODEV: case -ESHUTDOWN: - RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bSurpriseRemoved=true\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bSurpriseRemoved=true\n")); case -ENOENT: - padapter->bDriverStopped=true; - RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bDriverStopped=true\n")); + adapt->bDriverStopped = true; + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=true\n")); break; case -EPROTO: case -EOVERFLOW: { - struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - pHalData->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + haldata->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL; } precvbuf->reuse = true; - rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); break; case -EINPROGRESS: DBG_88E("ERROR: URB IS IN PROGRESS!/n"); @@ -639,13 +600,13 @@ _func_exit_; static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) { - unsigned long irqL; + unsigned long irql; int err; unsigned int pipe; - size_t tmpaddr=0; - size_t alignment=0; + size_t tmpaddr = 0; + size_t alignment = 0; u32 ret = _SUCCESS; - struct urb * purb = NULL; + struct urb *purb = NULL; struct recv_buf *precvbuf = (struct recv_buf *)rmem; struct adapter *adapter = pintfhdl->padapter; struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); @@ -657,12 +618,13 @@ _func_enter_; if (adapter->bDriverStopped || adapter->bSurpriseRemoved || adapter->pwrctrlpriv.pnp_bstop_trx) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + ("usb_read_port:(adapt->bDriverStopped ||adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); return _FAIL; } - if ((precvbuf->reuse == false) || (precvbuf->pskb == NULL)) { - if (NULL != (precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue))) + if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); + if (NULL != precvbuf->pskb) precvbuf->reuse = true; } @@ -670,14 +632,14 @@ _func_enter_; rtl8188eu_init_recvbuf(adapter, precvbuf); /* re-assign for linux based on skb */ - if ((precvbuf->reuse == false) || (precvbuf->pskb == NULL)) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) /* www.mail-archive.com/netdev@vger.kernel.org/msg17214.html */ + if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)) precvbuf->pskb = dev_alloc_skb(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); #else precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); #endif if (precvbuf->pskb == NULL) { - RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("init_recvbuf(): alloc_skb fail!\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n")); DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); return _FAIL; } @@ -736,23 +698,23 @@ _func_exit_; void rtl8188eu_xmit_tasklet(void *priv) { int ret = false; - struct adapter *padapter = (struct adapter*)priv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct adapter *adapt = (struct adapter *)priv; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; - if (check_fwstate(&padapter->mlmepriv, _FW_UNDER_SURVEY) == true) + if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY)) return; while (1) { - if ((padapter->bDriverStopped == true)|| - (padapter->bSurpriseRemoved== true) || - (padapter->bWritePortCancel == true)) { + if ((adapt->bDriverStopped) || + (adapt->bSurpriseRemoved) || + (adapt->bWritePortCancel)) { DBG_88E("xmit_tasklet => bDriverStopped or bSurpriseRemoved or bWritePortCancel\n"); break; } - ret = rtl8188eu_xmitframe_complete(padapter, pxmitpriv, NULL); + ret = rtl8188eu_xmitframe_complete(adapt, pxmitpriv, NULL); - if (ret==false) + if (!ret) break; } } @@ -777,9 +739,9 @@ void rtl8188eu_set_intf_ops(struct _io_ops *pops) _func_exit_; } -void rtl8188eu_set_hw_type(struct adapter *padapter) +void rtl8188eu_set_hw_type(struct adapter *adapt) { - padapter->chip_type = RTL8188E; - padapter->HardwareType = HARDWARE_TYPE_RTL8188EU; + adapt->chip_type = RTL8188E; + adapt->HardwareType = HARDWARE_TYPE_RTL8188EU; DBG_88E("CHIP TYPE: RTL8188E\n"); } diff --git a/include/rtl8188e_hal.h b/include/rtl8188e_hal.h index 76c567e..8fd951f 100644 --- a/include/rtl8188e_hal.h +++ b/include/rtl8188e_hal.h @@ -496,5 +496,7 @@ void rtl8188e_stop_thread(struct adapter *padapter); void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter,int data_len); s32 rtl8188e_iol_efuse_patch(struct adapter * padapter); +void rtw_cancel_all_timer(struct adapter *padapter); +void _ps_open_RF(struct adapter *adapt); #endif //__RTL8188E_HAL_H__