VOID ODM_CfoTrackingReset( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PCFO_TRACKING pCfoTrack = (PCFO_TRACKING)PhyDM_Get_Structure( pDM_Odm, PHYDM_CFOTRACK); pCfoTrack->DefXCap = odm_GetDefaultCrytaltalCap(pDM_Odm); pCfoTrack->bAdjust = TRUE; if(pCfoTrack->CrystalCap > pCfoTrack->DefXCap) { odm_SetCrystalCap(pDM_Odm, pCfoTrack->CrystalCap - 1); ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTrackingReset(): approch default value (0x%x)\n", pCfoTrack->CrystalCap)); } else if (pCfoTrack->CrystalCap < pCfoTrack->DefXCap) { odm_SetCrystalCap(pDM_Odm, pCfoTrack->CrystalCap + 1); ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTrackingReset(): approch default value (0x%x)\n", pCfoTrack->CrystalCap)); } #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) odm_SetATCStatus(pDM_Odm, TRUE); #endif }
VOID odm_SetCrystalCap( IN PVOID pDM_VOID, IN u1Byte CrystalCap ) { #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PCFO_TRACKING pCfoTrack = (PCFO_TRACKING)PhyDM_Get_Structure( pDM_Odm, PHYDM_CFOTRACK); BOOLEAN bEEPROMCheck; #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) PADAPTER Adapter = pDM_Odm->Adapter; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); bEEPROMCheck = (pHalData->EEPROMVersion >= 0x01)?TRUE:FALSE; #else bEEPROMCheck = TRUE; #endif if(pCfoTrack->CrystalCap == CrystalCap) return; pCfoTrack->CrystalCap = CrystalCap; if(pDM_Odm->SupportICType & ODM_RTL8192D) { ODM_SetBBReg(pDM_Odm, REG_AFE_XTAL_CTRL, 0x000000F0, CrystalCap & 0x0F); ODM_SetBBReg(pDM_Odm, REG_AFE_PLL_CTRL, 0xF0000000, ((CrystalCap & 0xF0) >> 4)); }
VOID ODM_ParsingCFO( IN PVOID pDM_VOID, IN PVOID pPktinfo_VOID, IN s1Byte* pcfotail ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PODM_PACKET_INFO_T pPktinfo = (PODM_PACKET_INFO_T)pPktinfo_VOID; PCFO_TRACKING pCfoTrack = (PCFO_TRACKING)PhyDM_Get_Structure( pDM_Odm, PHYDM_CFOTRACK); u1Byte i; if(!(pDM_Odm->SupportAbility & ODM_BB_CFO_TRACKING)) return; #if(DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) if(pPktinfo->bPacketMatchBSSID) #else if(pPktinfo->StationID != 0) #endif { //3 Update CFO report for path-A & path-B // Only paht-A and path-B have CFO tail and short CFO for(i = ODM_RF_PATH_A; i <= ODM_RF_PATH_B; i++) { pCfoTrack->CFO_tail[i] = (int)pcfotail[i]; } //3 Update packet counter if(pCfoTrack->packetCount == 0xffffffff) pCfoTrack->packetCount = 0; else pCfoTrack->packetCount++; } }
VOID odm_SetCrystalCap( IN PVOID pDM_VOID, IN u1Byte CrystalCap ) { #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PCFO_TRACKING pCfoTrack = (PCFO_TRACKING)PhyDM_Get_Structure( pDM_Odm, PHYDM_CFOTRACK); BOOLEAN bEEPROMCheck; #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) PADAPTER Adapter = pDM_Odm->Adapter; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); bEEPROMCheck = (pHalData->EEPROMVersion >= 0x01)?TRUE:FALSE; #else bEEPROMCheck = TRUE; #endif if(pCfoTrack->CrystalCap == CrystalCap) return; pCfoTrack->CrystalCap = CrystalCap; if (pDM_Odm->SupportICType & (ODM_RTL8188E | ODM_RTL8188F)) { /* write 0x24[22:17] = 0x24[16:11] = CrystalCap */ CrystalCap = CrystalCap & 0x3F; ODM_SetBBReg(pDM_Odm, REG_AFE_XTAL_CTRL, 0x007ff800, (CrystalCap|(CrystalCap << 6))); } else if (pDM_Odm->SupportICType & ODM_RTL8812) { /* write 0x2C[30:25] = 0x2C[24:19] = CrystalCap */ CrystalCap = CrystalCap & 0x3F; ODM_SetBBReg(pDM_Odm, REG_MAC_PHY_CTRL, 0x7FF80000, (CrystalCap|(CrystalCap << 6))); } else if (((pDM_Odm->SupportICType & ODM_RTL8723A) && bEEPROMCheck) || (pDM_Odm->SupportICType & (ODM_RTL8703B|ODM_RTL8723B|ODM_RTL8192E|ODM_RTL8821))) { /* 0x2C[23:18] = 0x2C[17:12] = CrystalCap */ CrystalCap = CrystalCap & 0x3F; ODM_SetBBReg(pDM_Odm, REG_MAC_PHY_CTRL, 0x00FFF000, (CrystalCap|(CrystalCap << 6))); } else if (pDM_Odm->SupportICType & ODM_RTL8821B) { /* write 0x28[6:1] = 0x24[30:25] = CrystalCap */ CrystalCap = CrystalCap & 0x3F; ODM_SetBBReg(pDM_Odm, REG_AFE_XTAL_CTRL, 0x7E000000, CrystalCap); ODM_SetBBReg(pDM_Odm, REG_AFE_PLL_CTRL, 0x7E, CrystalCap); } else if (pDM_Odm->SupportICType & ODM_RTL8814A) { /* write 0x2C[26:21] = 0x2C[20:15] = CrystalCap */ CrystalCap = CrystalCap & 0x3F; ODM_SetBBReg(pDM_Odm, REG_MAC_PHY_CTRL, 0x07FF8000, (CrystalCap|(CrystalCap << 6))); } else if (pDM_Odm->SupportICType & ODM_RTL8822B) { /* write 0x24[30:25] = 0x28[6:1] = CrystalCap */ CrystalCap = CrystalCap & 0x3F; ODM_SetBBReg(pDM_Odm, REG_AFE_XTAL_CTRL, 0x7e000000, CrystalCap); ODM_SetBBReg(pDM_Odm, REG_AFE_PLL_CTRL, 0x7e, CrystalCap); } else { ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("odm_SetCrystalCap(): Use default setting.\n")); ODM_SetBBReg(pDM_Odm, REG_MAC_PHY_CTRL, 0xFFF000, (CrystalCap|(CrystalCap << 6))); } ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("odm_SetCrystalCap(): CrystalCap = 0x%x\n", CrystalCap)); #endif }
VOID Phydm_CheckEnvironment( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PADAPTIVITY_STATISTICS Adaptivity = (PADAPTIVITY_STATISTICS)PhyDM_Get_Structure(pDM_Odm, PHYDM_ADAPTIVITY); BOOLEAN isCleanEnvironment = FALSE; if (Adaptivity->bFirstLink == TRUE) { if (pDM_Odm->SupportICType & (ODM_RTL8814A|ODM_RTL8195A)) pDM_Odm->adaptivity_flag = FALSE; else pDM_Odm->adaptivity_flag = TRUE; Adaptivity->bFirstLink = FALSE; return; } else { if (Adaptivity->NHMWait < 3) { /*Start enter NHM after 4 NHMWait*/ Adaptivity->NHMWait++; Phydm_NHMCounterStatistics(pDM_Odm); return; } else { Phydm_NHMCounterStatistics(pDM_Odm); isCleanEnvironment = Phydm_CalNHMcnt(pDM_Odm); if (isCleanEnvironment == TRUE) { #if(DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) pDM_Odm->TH_L2H_ini = pDM_Odm->TH_L2H_ini_backup; /*mode 1*/ pDM_Odm->TH_EDCCA_HL_diff = Adaptivity->TH_EDCCA_HL_diff_backup; #endif pDM_Odm->Adaptivity_enable = TRUE; if (pDM_Odm->SupportICType & (ODM_RTL8814A|ODM_RTL8195A)) pDM_Odm->adaptivity_flag = FALSE; else pDM_Odm->adaptivity_flag = TRUE; } else { #if(DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) Phydm_SetEDCCAThreshold(pDM_Odm, 0x7f, 0x7f); #else pDM_Odm->TH_L2H_ini = Adaptivity->TH_L2H_ini_mode2; /*for AP mode 2*/ pDM_Odm->TH_EDCCA_HL_diff = Adaptivity->TH_EDCCA_HL_diff_mode2; #endif pDM_Odm->adaptivity_flag = FALSE; pDM_Odm->Adaptivity_enable = FALSE; } Adaptivity->NHMWait = 0; Adaptivity->bFirstLink = TRUE; Adaptivity->bCheck = TRUE; } } }
VOID ODM_CfoTrackingInit( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PCFO_TRACKING pCfoTrack = (PCFO_TRACKING)PhyDM_Get_Structure( pDM_Odm, PHYDM_CFOTRACK); pCfoTrack->DefXCap = pCfoTrack->CrystalCap = odm_GetDefaultCrytaltalCap(pDM_Odm); pCfoTrack->bATCStatus = odm_GetATCStatus(pDM_Odm); pCfoTrack->bAdjust = TRUE; ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking_init()=========> \n")); ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking_init(): bATCStatus = %d, CrystalCap = 0x%x \n",pCfoTrack->bATCStatus, pCfoTrack->DefXCap)); }
VOID odm_SetATCStatus( IN PVOID pDM_VOID, IN BOOLEAN ATCStatus ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PCFO_TRACKING pCfoTrack = (PCFO_TRACKING)PhyDM_Get_Structure( pDM_Odm, PHYDM_CFOTRACK); if(pCfoTrack->bATCStatus == ATCStatus) return; ODM_SetBBReg(pDM_Odm, ODM_REG(BB_ATC,pDM_Odm), ODM_BIT(BB_ATC,pDM_Odm), ATCStatus); pCfoTrack->bATCStatus = ATCStatus; }
VOID Phydm_CheckAdaptivity( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PADAPTIVITY_STATISTICS Adaptivity = (PADAPTIVITY_STATISTICS)PhyDM_Get_Structure(pDM_Odm, PHYDM_ADAPTIVITY); if (pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY) { #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) if (pDM_Odm->APTotalNum > Adaptivity->APNumTH) { pDM_Odm->Adaptivity_enable = FALSE; pDM_Odm->adaptivity_flag = FALSE; Phydm_SetEDCCAThreshold(pDM_Odm, 0x7f, 0x7f); ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("AP total num > %d!!, disable adaptivity\n", Adaptivity->APNumTH)); } else #endif { if (Adaptivity->DynamicLinkAdaptivity == TRUE) { if (pDM_Odm->bLinked && Adaptivity->bCheck == FALSE) { Phydm_NHMCounterStatistics(pDM_Odm); Phydm_CheckEnvironment(pDM_Odm); } else if (!pDM_Odm->bLinked) Adaptivity->bCheck = FALSE; } else { pDM_Odm->Adaptivity_enable = TRUE; if (pDM_Odm->SupportICType & (ODM_RTL8814A|ODM_RTL8195A)) pDM_Odm->adaptivity_flag = FALSE; else pDM_Odm->adaptivity_flag = TRUE; } } } else { pDM_Odm->Adaptivity_enable = FALSE; pDM_Odm->adaptivity_flag = FALSE; } }
VOID Phydm_Adaptivity( IN PVOID pDM_VOID, IN u1Byte IGI ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; s1Byte TH_L2H_dmc, TH_H2L_dmc, L2H_nolink_Band4 = 0x7f, H2L_nolink_Band4 = 0x7f; s1Byte Diff, IGI_target; BOOLEAN EDCCA_State = FALSE; PFALSE_ALARM_STATISTICS FalseAlmCnt = (PFALSE_ALARM_STATISTICS)PhyDM_Get_Structure( pDM_Odm, PHYDM_FALSEALMCNT); #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) PADAPTER pAdapter = pDM_Odm->Adapter; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); BOOLEAN bFwCurrentInPSMode=FALSE; PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo); pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_FW_PSMODE_STATUS, (pu1Byte)(&bFwCurrentInPSMode)); // Disable EDCCA mode while under LPS mode, added by Roger, 2012.09.14. if(bFwCurrentInPSMode) return; #endif if(!(pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY)) { ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("Go to odm_DynamicEDCCA() \n")); // Add by Neil Chen to enable edcca to MP Platform #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) // Adjust EDCCA. if(pDM_Odm->SupportICType & ODM_IC_11N_SERIES) Phydm_DynamicEDCCA(pDM_Odm); #endif return; } #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) if(pMgntInfo->RegEnableAdaptivity== 2) { if(pDM_Odm->Carrier_Sense_enable == FALSE) // check domain Code for Adaptivity or CarrierSense { if ((*pDM_Odm->pBandType == ODM_BAND_5G) && !(pDM_Odm->odm_Regulation5G == REGULATION_ETSI || pDM_Odm->odm_Regulation5G == REGULATION_WW)) { ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("Adaptivity skip 5G domain code : %d \n", pDM_Odm->odm_Regulation5G)); return; } else if((*pDM_Odm->pBandType == ODM_BAND_2_4G) && !(pDM_Odm->odm_Regulation2_4G == REGULATION_ETSI || pDM_Odm->odm_Regulation2_4G == REGULATION_WW)) { ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("Adaptivity skip 2.4G domain code : %d \n", pDM_Odm->odm_Regulation2_4G)); return; } else if ((*pDM_Odm->pBandType != ODM_BAND_2_4G) && (*pDM_Odm->pBandType != ODM_BAND_5G)) { ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("Adaptivity neither 2G nor 5G band, return\n")); return; } } else { if ((*pDM_Odm->pBandType == ODM_BAND_5G) && !(pDM_Odm->odm_Regulation5G == REGULATION_MKK || pDM_Odm->odm_Regulation5G == REGULATION_WW)) { ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("CarrierSense skip 5G domain code : %d\n", pDM_Odm->odm_Regulation5G)); return; } else if((*pDM_Odm->pBandType == ODM_BAND_2_4G) && !(pDM_Odm->odm_Regulation2_4G == REGULATION_MKK || pDM_Odm->odm_Regulation2_4G == REGULATION_WW)) { ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("CarrierSense skip 2.4G domain code : %d\n", pDM_Odm->odm_Regulation2_4G)); return; } else if ((*pDM_Odm->pBandType != ODM_BAND_2_4G) && (*pDM_Odm->pBandType != ODM_BAND_5G)) { ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("CarrierSense neither 2G nor 5G band, return\n")); return; } } } #endif ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("odm_Adaptivity() =====> \n")); ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("IGI_Base=0x%x, TH_L2H_ini = %d, TH_EDCCA_HL_diff = %d\n", pDM_Odm->IGI_Base, pDM_Odm->TH_L2H_ini, pDM_Odm->TH_EDCCA_HL_diff)); if(pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) { // fix AC series when enable EDCCA hang issue ODM_SetBBReg(pDM_Odm, 0x800, BIT10, 1); //ADC_mask disable ODM_SetBBReg(pDM_Odm, 0x800, BIT10, 0); //ADC_mask enable } if(*pDM_Odm->pBandWidth == ODM_BW20M) //CHANNEL_WIDTH_20 IGI_target = pDM_Odm->IGI_Base; else if(*pDM_Odm->pBandWidth == ODM_BW40M) IGI_target = pDM_Odm->IGI_Base + 2; else if(*pDM_Odm->pBandWidth == ODM_BW80M) IGI_target = pDM_Odm->IGI_Base + 2; else IGI_target = pDM_Odm->IGI_Base; pDM_Odm->IGI_target = (u1Byte) IGI_target; if(*pDM_Odm->pChannel >= 149) // Band4 -> for AP : mode2 { #if (DM_ODM_SUPPORT_TYPE & ODM_AP) if(pDM_Odm->bLinked) { if(pDM_Odm->SupportICType & ODM_RTL8814A) { L2H_nolink_Band4 = (s1Byte)pDM_Odm->TH_L2H_ini_mode2 + IGI_target; H2L_nolink_Band4 = L2H_nolink_Band4 - pDM_Odm->TH_EDCCA_HL_diff_mode2; } else { Diff = IGI_target -(s1Byte)IGI; L2H_nolink_Band4 = pDM_Odm->TH_L2H_ini_mode2 + Diff; if(L2H_nolink_Band4 > 10) L2H_nolink_Band4 = 10; H2L_nolink_Band4 = L2H_nolink_Band4 - pDM_Odm->TH_EDCCA_HL_diff_mode2; } } else { L2H_nolink_Band4 = 0x7f; H2L_nolink_Band4 = 0x7f; } Phydm_SetEDCCAThreshold(pDM_Odm, H2L_nolink_Band4, L2H_nolink_Band4); return; #endif } ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("BandWidth=%s, IGI_target=0x%x, FABound = %d, DynamicLinkAdaptivity = %d\n", (*pDM_Odm->pBandWidth==ODM_BW80M)?"80M":((*pDM_Odm->pBandWidth==ODM_BW40M)?"40M":"20M"), IGI_target, pDM_Odm->FABound, pDM_Odm->DynamicLinkAdaptivity)); ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("RSSI_min = %d, AdapIGIUpper= 0x%x, adaptivity_flag = %d, Adaptivity_enable = %d\n", pDM_Odm->RSSI_Min, pDM_Odm->Adaptivity_IGI_upper, pDM_Odm->adaptivity_flag, pDM_Odm->Adaptivity_enable)); if((pDM_Odm->DynamicLinkAdaptivity == TRUE) && (!pDM_Odm->bLinked) && (pDM_Odm->Adaptivity_enable == FALSE)) { Phydm_SetEDCCAThreshold(pDM_Odm, 0x7f, 0x7f); ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("In DynamicLink mode(noisy) and No link, Turn off EDCCA!!\n")); return; } #if (!(DM_ODM_SUPPORT_TYPE & ODM_AP)) else if((pDM_Odm->DynamicLinkAdaptivity == TRUE) && (pDM_Odm->Adaptivity_enable == FALSE)) { Phydm_SetEDCCAThreshold(pDM_Odm, 0x7f, 0x7f); ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("In DynamicLink mode(noisy) disable EDCCA, return!!\n")); return; } #endif if((pDM_Odm->SupportICType & ODM_RTL8723B) && (pDM_Odm->CutVersion & ODM_CUT_B) && (FalseAlmCnt->Cnt_all > pDM_Odm->FABound) && (IGI == pDM_Odm->Adaptivity_IGI_upper)) { pDM_Odm->Adaptivity_IGI_upper = pDM_Odm->Adaptivity_IGI_upper + 3; ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("FA > %d, IGI upper bound + 3!!\n", pDM_Odm->FABound)); } if(pDM_Odm->SupportICType & ODM_RTL8814A) { TH_L2H_dmc = (s1Byte)pDM_Odm->TH_L2H_ini + IGI_target; TH_H2L_dmc = TH_L2H_dmc - pDM_Odm->TH_EDCCA_HL_diff; } else { Diff = IGI_target -(s1Byte)IGI; TH_L2H_dmc = pDM_Odm->TH_L2H_ini + Diff; if(TH_L2H_dmc > 10) TH_L2H_dmc = 10; TH_H2L_dmc = TH_L2H_dmc - pDM_Odm->TH_EDCCA_HL_diff; //replace lower bound to prevent EDCCA always equal 1 if(TH_H2L_dmc < pDM_Odm->H2L_lb) TH_H2L_dmc = pDM_Odm->H2L_lb; if(TH_L2H_dmc < pDM_Odm->L2H_lb) TH_L2H_dmc = pDM_Odm->L2H_lb; } ODM_RT_TRACE(pDM_Odm,PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("IGI=0x%x, TH_L2H_dmc = %d, TH_H2L_dmc = %d\n", IGI, TH_L2H_dmc, TH_H2L_dmc)); Phydm_SetEDCCAThreshold(pDM_Odm, TH_H2L_dmc, TH_L2H_dmc); return; }
VOID odm_DynamicPrimaryCCA( IN PDM_ODM_T pDM_Odm ) { PADAPTER Adapter = pDM_Odm->Adapter; // for NIC #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN)) PRT_WLAN_STA pEntry; #endif PFALSE_ALARM_STATISTICS FalseAlmCnt = (PFALSE_ALARM_STATISTICS)PhyDM_Get_Structure( pDM_Odm , PHYDM_FALSEALMCNT); pPri_CCA_T PrimaryCCA = &(pDM_Odm->DM_PriCCA); BOOLEAN Is40MHz; BOOLEAN Client_40MHz = FALSE, Client_tmp = FALSE; // connected client BW BOOLEAN bConnected = FALSE; // connected or not static u1Byte Client_40MHz_pre = 0; static u8Byte lastTxOkCnt = 0; static u8Byte lastRxOkCnt = 0; static u4Byte Counter = 0; static u1Byte Delay = 1; u8Byte curTxOkCnt; u8Byte curRxOkCnt; u1Byte SecCHOffset; u1Byte i; if(!(pDM_Odm->SupportAbility & ODM_BB_PRIMARY_CCA)) return; #if((DM_ODM_SUPPORT_TYPE==ODM_ADSL) ||( DM_ODM_SUPPORT_TYPE==ODM_CE)) return; #else if(pDM_Odm->SupportICType != ODM_RTL8188E) return; Is40MHz = *(pDM_Odm->pBandWidth); SecCHOffset = *(pDM_Odm->pSecChOffset); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("Second CH Offset = %d\n", SecCHOffset)); #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) if(Is40MHz==1) SecCHOffset = SecCHOffset%2+1; // NIC's definition is reverse to AP 1:secondary below, 2: secondary above ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("Second CH Offset = %d\n", SecCHOffset)); //3 Check Current WLAN Traffic curTxOkCnt = Adapter->TxStats.NumTxBytesUnicast - lastTxOkCnt; curRxOkCnt = Adapter->RxStats.NumRxBytesUnicast - lastRxOkCnt; lastTxOkCnt = Adapter->TxStats.NumTxBytesUnicast; lastRxOkCnt = Adapter->RxStats.NumRxBytesUnicast; #elif (DM_ODM_SUPPORT_TYPE == ODM_AP) //3 Check Current WLAN Traffic curTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast)-lastTxOkCnt; curRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast)-lastRxOkCnt; lastTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast); lastRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast); #endif //==================Debug Message==================== ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("TP = %llu\n", curTxOkCnt+curRxOkCnt)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("Is40MHz = %d\n", Is40MHz)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("BW_LSC = %d\n", FalseAlmCnt->Cnt_BW_LSC)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("BW_USC = %d\n", FalseAlmCnt->Cnt_BW_USC)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("CCA OFDM = %d\n", FalseAlmCnt->Cnt_OFDM_CCA)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("CCA CCK = %d\n", FalseAlmCnt->Cnt_CCK_CCA)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("OFDM FA = %d\n", FalseAlmCnt->Cnt_Ofdm_fail)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("CCK FA = %d\n", FalseAlmCnt->Cnt_Cck_fail)); //================================================ #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) if (ACTING_AS_AP(Adapter)) // primary cca process only do at AP mode #endif { #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("ACTING as AP mode=%d\n", ACTING_AS_AP(Adapter))); //3 To get entry's connection and BW infomation status. for(i=0;i<ASSOCIATE_ENTRY_NUM;i++) { if(IsAPModeExist(Adapter)&&GetFirstExtAdapter(Adapter)!=NULL) pEntry=AsocEntry_EnumStation(GetFirstExtAdapter(Adapter), i); else pEntry=AsocEntry_EnumStation(GetDefaultAdapter(Adapter), i); if(pEntry!=NULL) { Client_tmp = pEntry->BandWidth; // client BW ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("Client_BW=%d\n", Client_tmp)); if(Client_tmp>Client_40MHz) Client_40MHz = Client_tmp; // 40M/20M coexist => 40M priority is High if(pEntry->bAssociated) { bConnected=TRUE; // client is connected or not break; } } else { break; } } #elif (DM_ODM_SUPPORT_TYPE == ODM_AP) //3 To get entry's connection and BW infomation status. PSTA_INFO_T pstat; for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++) { pstat = pDM_Odm->pODM_StaInfo[i]; if(IS_STA_VALID(pstat) ) { Client_tmp = pstat->tx_bw; if(Client_tmp>Client_40MHz) Client_40MHz = Client_tmp; // 40M/20M coexist => 40M priority is High bConnected = TRUE; } } #endif ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("bConnected=%d\n", bConnected)); ODM_RT_TRACE(pDM_Odm,ODM_COMP_DYNAMIC_PRICCA, ODM_DBG_LOUD, ("Is Client 40MHz=%d\n", Client_40MHz)); //1 Monitor whether the interference exists or not if(PrimaryCCA->Monitor_flag == 1) { if(SecCHOffset == 1) // secondary channel is below the primary channel { if((FalseAlmCnt->Cnt_OFDM_CCA > 500)&&(FalseAlmCnt->Cnt_BW_LSC > FalseAlmCnt->Cnt_BW_USC+500)) { if(FalseAlmCnt->Cnt_Ofdm_fail > FalseAlmCnt->Cnt_OFDM_CCA>>1) { PrimaryCCA->intf_type = 1; PrimaryCCA->PriCCA_flag = 1; ODM_SetBBReg(pDM_Odm, 0xc6c, BIT8|BIT7, 2); // USC MF if(PrimaryCCA->DupRTS_flag == 1) PrimaryCCA->DupRTS_flag = 0; } else { PrimaryCCA->intf_type = 2; if(PrimaryCCA->DupRTS_flag == 0) PrimaryCCA->DupRTS_flag = 1; } } else // interferecne disappear { PrimaryCCA->DupRTS_flag = 0; PrimaryCCA->intf_flag = 0; PrimaryCCA->intf_type = 0; } } else if(SecCHOffset == 2) // secondary channel is above the primary channel
VOID ODM_CfoTracking( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PCFO_TRACKING pCfoTrack = (PCFO_TRACKING)PhyDM_Get_Structure( pDM_Odm, PHYDM_CFOTRACK); int CFO_kHz_A, CFO_kHz_B, CFO_ave = 0; int CFO_ave_diff; int CrystalCap = (int)pCfoTrack->CrystalCap; u1Byte Adjust_Xtal = 1; //4 Support ability if(!(pDM_Odm->SupportAbility & ODM_BB_CFO_TRACKING)) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Return: SupportAbility ODM_BB_CFO_TRACKING is disabled\n")); return; } ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking()=========> \n")); if(!pDM_Odm->bLinked || !pDM_Odm->bOneEntryOnly) { //4 No link or more than one entry ODM_CfoTrackingReset(pDM_Odm); ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Reset: bLinked = %d, bOneEntryOnly = %d\n", pDM_Odm->bLinked, pDM_Odm->bOneEntryOnly)); } else { //3 1. CFO Tracking //4 1.1 No new packet if(pCfoTrack->packetCount == pCfoTrack->packetCount_pre) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): packet counter doesn't change\n")); return; } pCfoTrack->packetCount_pre = pCfoTrack->packetCount; //4 1.2 Calculate CFO CFO_kHz_A = (int)((pCfoTrack->CFO_tail[0] * 3125) / 10)>>7; /* CFO_tail[1:0] is S(8,7), (num_subcarrier>>7) x 312.5K = CFO value(K Hz) */ CFO_kHz_B = (int)((pCfoTrack->CFO_tail[1] * 3125) / 10)>>7; if(pDM_Odm->RFType < ODM_2T2R) CFO_ave = CFO_kHz_A; else CFO_ave = (int)(CFO_kHz_A + CFO_kHz_B) >> 1; ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): CFO_kHz_A = %dkHz, CFO_kHz_B = %dkHz, CFO_ave = %dkHz\n", CFO_kHz_A, CFO_kHz_B, CFO_ave)); //4 1.3 Avoid abnormal large CFO CFO_ave_diff = (pCfoTrack->CFO_ave_pre >= CFO_ave)?(pCfoTrack->CFO_ave_pre - CFO_ave):(CFO_ave - pCfoTrack->CFO_ave_pre); if(CFO_ave_diff > 20 && pCfoTrack->largeCFOHit == 0 && !pCfoTrack->bAdjust) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): first large CFO hit\n")); pCfoTrack->largeCFOHit = 1; return; } else pCfoTrack->largeCFOHit = 0; pCfoTrack->CFO_ave_pre = CFO_ave; //4 1.4 Dynamic Xtal threshold if(pCfoTrack->bAdjust == FALSE) { if(CFO_ave > CFO_TH_XTAL_HIGH || CFO_ave < (-CFO_TH_XTAL_HIGH)) pCfoTrack->bAdjust = TRUE; } else { if(CFO_ave < CFO_TH_XTAL_LOW && CFO_ave > (-CFO_TH_XTAL_LOW)) pCfoTrack->bAdjust = FALSE; } #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) //4 1.5 BT case: Disable CFO tracking if(pDM_Odm->bBtEnabled) { pCfoTrack->bAdjust = FALSE; odm_SetCrystalCap(pDM_Odm, pCfoTrack->DefXCap); ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Disable CFO tracking for BT!!\n")); } /* //4 1.6 Big jump if(pCfoTrack->bAdjust) { if(CFO_ave > CFO_TH_XTAL_LOW) Adjust_Xtal = Adjust_Xtal + ((CFO_ave - CFO_TH_XTAL_LOW) >> 2); else if(CFO_ave < (-CFO_TH_XTAL_LOW)) Adjust_Xtal = Adjust_Xtal + ((CFO_TH_XTAL_LOW - CFO_ave) >> 2); ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Crystal cap offset = %d\n", Adjust_Xtal)); } */ #endif //4 1.7 Adjust Crystal Cap. if(pCfoTrack->bAdjust) { if(CFO_ave > CFO_TH_XTAL_LOW) CrystalCap = CrystalCap + Adjust_Xtal; else if(CFO_ave < (-CFO_TH_XTAL_LOW)) CrystalCap = CrystalCap - Adjust_Xtal; if(CrystalCap > 0x3f) CrystalCap = 0x3f; else if (CrystalCap < 0) CrystalCap = 0; odm_SetCrystalCap(pDM_Odm, (u1Byte)CrystalCap); } ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Crystal cap = 0x%x, Default Crystal cap = 0x%x\n", pCfoTrack->CrystalCap, pCfoTrack->DefXCap)); #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) if(pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) return; //3 2. Dynamic ATC switch if(CFO_ave < CFO_TH_ATC && CFO_ave > -CFO_TH_ATC) { odm_SetATCStatus(pDM_Odm, FALSE); ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Disable ATC!!\n")); } else { odm_SetATCStatus(pDM_Odm, TRUE); ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Enable ATC!!\n")); } #endif } }
VOID Phydm_Adaptivity( IN PVOID pDM_VOID, IN u1Byte IGI ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; s1Byte TH_L2H_dmc, TH_H2L_dmc; s1Byte Diff, IGI_target; PADAPTIVITY_STATISTICS Adaptivity = (PADAPTIVITY_STATISTICS)PhyDM_Get_Structure(pDM_Odm, PHYDM_ADAPTIVITY); #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) PADAPTER pAdapter = pDM_Odm->Adapter; BOOLEAN bFwCurrentInPSMode = FALSE; PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo); pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_FW_PSMODE_STATUS, (pu1Byte)(&bFwCurrentInPSMode)); /*Disable EDCCA mode while under LPS mode, added by Roger, 2012.09.14.*/ if (bFwCurrentInPSMode) return; #endif if (!(pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY)) { ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("Go to odm_DynamicEDCCA()\n")); /*Add by Neil Chen to enable edcca to MP Platform */ #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) /*Adjust EDCCA.*/ if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) Phydm_DynamicEDCCA(pDM_Odm); #endif return; } #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) if (Phydm_CheckChannelPlan(pDM_Odm)) return; if (pDM_Odm->APTotalNum > Adaptivity->APNumTH) return; #endif ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("odm_Adaptivity() =====>\n")); ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("IGI_Base=0x%x, TH_L2H_ini = %d, TH_EDCCA_HL_diff = %d\n", Adaptivity->IGI_Base, pDM_Odm->TH_L2H_ini, pDM_Odm->TH_EDCCA_HL_diff)); #if (RTL8195A_SUPPORT == 0) if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) { /*fix AC series when enable EDCCA hang issue*/ ODM_SetBBReg(pDM_Odm, 0x800, BIT10, 1); /*ADC_mask disable*/ ODM_SetBBReg(pDM_Odm, 0x800, BIT10, 0); /*ADC_mask enable*/ } #endif if (*pDM_Odm->pBandWidth == ODM_BW20M) /*CHANNEL_WIDTH_20*/ IGI_target = Adaptivity->IGI_Base; else if (*pDM_Odm->pBandWidth == ODM_BW40M) IGI_target = Adaptivity->IGI_Base + 2; #if (RTL8195A_SUPPORT == 0) else if (*pDM_Odm->pBandWidth == ODM_BW80M) IGI_target = Adaptivity->IGI_Base + 2; #endif else IGI_target = Adaptivity->IGI_Base; Adaptivity->IGI_target = (u1Byte) IGI_target; if (*pDM_Odm->pChannel >= 149) { /*Band4 -> for AP : mode2*/ #if (DM_ODM_SUPPORT_TYPE & ODM_AP) s1Byte L2H_nolink_Band4 = 0x7f, H2L_nolink_Band4 = 0x7f; if (pDM_Odm->bLinked) { if (pDM_Odm->SupportICType & ODM_RTL8814A) { L2H_nolink_Band4 = (s1Byte)Adaptivity->TH_L2H_ini_mode2 + IGI_target; H2L_nolink_Band4 = L2H_nolink_Band4 - Adaptivity->TH_EDCCA_HL_diff_mode2; } else { Diff = IGI_target - (s1Byte)IGI; L2H_nolink_Band4 = Adaptivity->TH_L2H_ini_mode2 + Diff; if (L2H_nolink_Band4 > 10) L2H_nolink_Band4 = 10; H2L_nolink_Band4 = L2H_nolink_Band4 - Adaptivity->TH_EDCCA_HL_diff_mode2; } } else { L2H_nolink_Band4 = 0x7f; H2L_nolink_Band4 = 0x7f; } Phydm_SetEDCCAThreshold(pDM_Odm, H2L_nolink_Band4, L2H_nolink_Band4); return; #endif } ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("BandWidth=%s, IGI_target=0x%x, DynamicLinkAdaptivity = %d\n", (*pDM_Odm->pBandWidth == ODM_BW80M) ? "80M" : ((*pDM_Odm->pBandWidth == ODM_BW40M) ? "40M" : "20M"), IGI_target, Adaptivity->DynamicLinkAdaptivity)); ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("RSSI_min = %d, AdapIGIUpper= 0x%x, adaptivity_flag = %d, Adaptivity_enable = %d\n", pDM_Odm->RSSI_Min, pDM_Odm->Adaptivity_IGI_upper, pDM_Odm->adaptivity_flag, pDM_Odm->Adaptivity_enable)); if ((Adaptivity->DynamicLinkAdaptivity == TRUE) && (!pDM_Odm->bLinked) && (pDM_Odm->Adaptivity_enable == FALSE)) { Phydm_SetEDCCAThreshold(pDM_Odm, 0x7f, 0x7f); ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("In DynamicLink mode(noisy) and No link, Turn off EDCCA!!\n")); return; } #if (!(DM_ODM_SUPPORT_TYPE & ODM_AP)) else if ((Adaptivity->DynamicLinkAdaptivity == TRUE) && (pDM_Odm->Adaptivity_enable == FALSE)) { Phydm_SetEDCCAThreshold(pDM_Odm, 0x7f, 0x7f); ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("In DynamicLink mode(noisy) disable EDCCA, return!!\n")); return; } #endif if (pDM_Odm->SupportICType & (ODM_RTL8814A|ODM_RTL8195A)) { TH_L2H_dmc = (s1Byte)pDM_Odm->TH_L2H_ini + IGI_target; TH_H2L_dmc = TH_L2H_dmc - pDM_Odm->TH_EDCCA_HL_diff; } #if (RTL8195A_SUPPORT == 0) else { Diff = IGI_target - (s1Byte)IGI; TH_L2H_dmc = pDM_Odm->TH_L2H_ini + Diff; if (TH_L2H_dmc > 10) TH_L2H_dmc = 10; TH_H2L_dmc = TH_L2H_dmc - pDM_Odm->TH_EDCCA_HL_diff; /*replace lower bound to prevent EDCCA always equal 1*/ if (TH_H2L_dmc < Adaptivity->H2L_lb) TH_H2L_dmc = Adaptivity->H2L_lb; if (TH_L2H_dmc < Adaptivity->L2H_lb) TH_L2H_dmc = Adaptivity->L2H_lb; } #endif ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("IGI=0x%x, TH_L2H_dmc = %d, TH_H2L_dmc = %d\n", IGI, TH_L2H_dmc, TH_H2L_dmc)); ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("Adaptivity_IGI_upper=0x%x, H2L_lb = 0x%x, L2H_lb = 0x%x\n", pDM_Odm->Adaptivity_IGI_upper, Adaptivity->H2L_lb, Adaptivity->L2H_lb)); Phydm_SetEDCCAThreshold(pDM_Odm, TH_H2L_dmc, TH_L2H_dmc); return; }
VOID Phydm_AdaptivityInit( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PADAPTIVITY_STATISTICS Adaptivity = (PADAPTIVITY_STATISTICS)PhyDM_Get_Structure(pDM_Odm, PHYDM_ADAPTIVITY); #if(DM_ODM_SUPPORT_TYPE == ODM_WIN) PADAPTER pAdapter = pDM_Odm->Adapter; PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo); pDM_Odm->Carrier_Sense_enable = (BOOLEAN)pMgntInfo->RegEnableCarrierSense; pDM_Odm->DCbackoff = (u1Byte)pMgntInfo->RegDCbackoff; Adaptivity->DynamicLinkAdaptivity = (BOOLEAN)pMgntInfo->RegDmLinkAdaptivity; Adaptivity->APNumTH = (u1Byte)pMgntInfo->RegAPNumTH; #elif(DM_ODM_SUPPORT_TYPE == ODM_CE) pDM_Odm->Carrier_Sense_enable = (pDM_Odm->Adapter->registrypriv.adaptivity_mode != 0) ? TRUE : FALSE; pDM_Odm->DCbackoff = pDM_Odm->Adapter->registrypriv.adaptivity_dc_backoff; Adaptivity->DynamicLinkAdaptivity = (pDM_Odm->Adapter->registrypriv.adaptivity_dml != 0) ? TRUE : FALSE; #endif #if(DM_ODM_SUPPORT_TYPE & (ODM_CE|ODM_WIN)) if (pDM_Odm->Carrier_Sense_enable == FALSE) { #if(DM_ODM_SUPPORT_TYPE == ODM_WIN) if (pMgntInfo->RegL2HForAdaptivity != 0) pDM_Odm->TH_L2H_ini = pMgntInfo->RegL2HForAdaptivity; else #endif { pDM_Odm->TH_L2H_ini = 0xf5; } } else { #if(DM_ODM_SUPPORT_TYPE == ODM_WIN) if (pMgntInfo->RegL2HForAdaptivity != 0) pDM_Odm->TH_L2H_ini = pMgntInfo->RegL2HForAdaptivity; else #endif pDM_Odm->TH_L2H_ini = 0xa; } #if(DM_ODM_SUPPORT_TYPE == ODM_WIN) if (pMgntInfo->RegHLDiffForAdaptivity != 0) pDM_Odm->TH_EDCCA_HL_diff = pMgntInfo->RegHLDiffForAdaptivity; else #endif pDM_Odm->TH_EDCCA_HL_diff = 7; ODM_RT_TRACE(pDM_Odm, PHYDM_COMP_ADAPTIVITY, ODM_DBG_LOUD, ("TH_L2H_ini = 0x%x, TH_EDCCA_HL_diff = 0x%x\n", pDM_Odm->TH_L2H_ini, pDM_Odm->TH_EDCCA_HL_diff)); #elif (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) prtl8192cd_priv priv = pDM_Odm->priv; if (pDM_Odm->Carrier_Sense_enable) { pDM_Odm->TH_L2H_ini = 0xa; pDM_Odm->TH_EDCCA_HL_diff = 7; } else { pDM_Odm->TH_L2H_ini = pDM_Odm->TH_L2H_ini_backup; /*set by mib*/ pDM_Odm->TH_EDCCA_HL_diff = 7; } Adaptivity->TH_L2H_ini_mode2 = 20; Adaptivity->TH_EDCCA_HL_diff_mode2 = 8; Adaptivity->TH_EDCCA_HL_diff_backup = pDM_Odm->TH_EDCCA_HL_diff; if (priv->pshare->rf_ft_var.adaptivity_enable == 2) Adaptivity->DynamicLinkAdaptivity = TRUE; else Adaptivity->DynamicLinkAdaptivity = FALSE; #endif pDM_Odm->Adaptivity_IGI_upper = 0; pDM_Odm->Adaptivity_enable = FALSE; /*use this flag to decide enable or disable*/ Adaptivity->IGI_Base = 0x32; Adaptivity->IGI_target = 0x1c; Adaptivity->H2L_lb = 0; Adaptivity->L2H_lb = 0; Adaptivity->NHMWait = 0; Adaptivity->bCheck = FALSE; Adaptivity->bFirstLink = TRUE; Phydm_MACEDCCAState(pDM_Odm, PhyDM_DONT_IGNORE_EDCCA); /*Search pwdB lower bound*/ if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) ODM_SetBBReg(pDM_Odm, ODM_REG_DBG_RPT_11N, bMaskDWord, 0x208); #if (RTL8195A_SUPPORT == 0) else if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) ODM_SetBBReg(pDM_Odm, ODM_REG_DBG_RPT_11AC, bMaskDWord, 0x209); #endif #if (RTL8195A_SUPPORT == 1) if (pDM_Odm->SupportICType & ODM_RTL8195A) { ODM_SetBBReg(pDM_Odm, ODM_REG_EDCCA_DOWN_OPT_11N, BIT12 | BIT11 | BIT10, 0x7); /*interfernce need > 2^x us, and then EDCCA will be 1*/ ODM_SetBBReg(pDM_Odm, DOM_REG_EDCCA_DCNF_11N, BIT21 | BIT20, 0x1); /*0:rx_dfir, 1: dcnf_out, 2 :rx_iq, 3: rx_nbi_nf_out*/ } #else if (pDM_Odm->SupportICType & ODM_RTL8814A) { /*8814a no need to find pwdB lower bound, maybe*/ ODM_SetBBReg(pDM_Odm, ODM_REG_EDCCA_DOWN_OPT, BIT30 | BIT29 | BIT28, 0x7); /*interfernce need > 2^x us, and then EDCCA will be 1*/ ODM_SetBBReg(pDM_Odm, ODM_REG_ACBB_EDCCA_ENHANCE, BIT29 | BIT28, 0x1); /*0:rx_dfir, 1: dcnf_out, 2 :rx_iq, 3: rx_nbi_nf_out*/ } else Phydm_SearchPwdBLowerBound(pDM_Odm); #endif }
VOID Phydm_SearchPwdBLowerBound( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PADAPTIVITY_STATISTICS Adaptivity = (PADAPTIVITY_STATISTICS)PhyDM_Get_Structure(pDM_Odm, PHYDM_ADAPTIVITY); u4Byte value32 = 0; u1Byte cnt, IGI_Pause = 0x7f, IGI_Resume = 0x20, IGI = 0x45; /*IGI = 0x50 for cal EDCCA lower bound*/ u1Byte txEdcca1 = 0, txEdcca0 = 0; BOOLEAN bAdjust = TRUE; s1Byte TH_L2H_dmc, TH_H2L_dmc, IGI_target = 0x32; s1Byte Diff; Phydm_SetTRxMux(pDM_Odm, PhyDM_STANDBY_MODE, PhyDM_STANDBY_MODE); ODM_Write_DIG(pDM_Odm, IGI_Pause); Diff = IGI_target - (s1Byte)IGI; TH_L2H_dmc = pDM_Odm->TH_L2H_ini + Diff; if (TH_L2H_dmc > 10) TH_L2H_dmc = 10; TH_H2L_dmc = TH_L2H_dmc - pDM_Odm->TH_EDCCA_HL_diff; Phydm_SetEDCCAThreshold(pDM_Odm, TH_H2L_dmc, TH_L2H_dmc); ODM_delay_ms(5); while (bAdjust) { for (cnt = 0; cnt < 20; cnt++) { if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) value32 = ODM_GetBBReg(pDM_Odm, ODM_REG_RPT_11N, bMaskDWord); #if (RTL8195A_SUPPORT == 0) else if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) value32 = ODM_GetBBReg(pDM_Odm, ODM_REG_RPT_11AC, bMaskDWord); #endif if (value32 & BIT30 && (pDM_Odm->SupportICType & (ODM_RTL8723A | ODM_RTL8723B | ODM_RTL8188E))) txEdcca1 = txEdcca1 + 1; else if (value32 & BIT29) txEdcca1 = txEdcca1 + 1; else txEdcca0 = txEdcca0 + 1; } if (txEdcca1 > 1) { IGI = IGI - 1; TH_L2H_dmc = TH_L2H_dmc + 1; if (TH_L2H_dmc > 10) TH_L2H_dmc = 10; TH_H2L_dmc = TH_L2H_dmc - pDM_Odm->TH_EDCCA_HL_diff; Phydm_SetEDCCAThreshold(pDM_Odm, TH_H2L_dmc, TH_L2H_dmc); if (TH_L2H_dmc == 10) { bAdjust = FALSE; Adaptivity->H2L_lb = TH_H2L_dmc; Adaptivity->L2H_lb = TH_L2H_dmc; pDM_Odm->Adaptivity_IGI_upper = IGI; } txEdcca1 = 0; txEdcca0 = 0; } else { bAdjust = FALSE; Adaptivity->H2L_lb = TH_H2L_dmc; Adaptivity->L2H_lb = TH_L2H_dmc; pDM_Odm->Adaptivity_IGI_upper = IGI; txEdcca1 = 0; txEdcca0 = 0; } } pDM_Odm->Adaptivity_IGI_upper = pDM_Odm->Adaptivity_IGI_upper - pDM_Odm->DCbackoff; Adaptivity->H2L_lb = Adaptivity->H2L_lb + pDM_Odm->DCbackoff; Adaptivity->L2H_lb = Adaptivity->L2H_lb + pDM_Odm->DCbackoff; Phydm_SetTRxMux(pDM_Odm, PhyDM_TX_MODE, PhyDM_RX_MODE); ODM_Write_DIG(pDM_Odm, IGI_Resume); Phydm_SetEDCCAThreshold(pDM_Odm, 0x7f, 0x7f); /*resume to no link state*/ }