static void odm_HWAntDiv(struct odm_dm_struct *dm_odm) { u32 i, MinRSSI = 0xFF, AntDivMaxRSSI = 0, MaxRSSI = 0, LocalMinRSSI, LocalMaxRSSI; u32 Main_RSSI, Aux_RSSI; u8 RxIdleAnt = 0, TargetAnt = 7; struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable; struct sta_info *pEntry; for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { pEntry = dm_odm->pODM_StaInfo[i]; if (IS_STA_VALID(pEntry)) { /* 2 Caculate RSSI per Antenna */ Main_RSSI = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? (dm_fat_tbl->MainAnt_Sum[i]/dm_fat_tbl->MainAnt_Cnt[i]) : 0; Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i]/dm_fat_tbl->AuxAnt_Cnt[i]) : 0; TargetAnt = (Main_RSSI >= Aux_RSSI) ? MAIN_ANT : AUX_ANT; ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("MacID=%d, MainAnt_Sum=%d, MainAnt_Cnt=%d\n", i, dm_fat_tbl->MainAnt_Sum[i], dm_fat_tbl->MainAnt_Cnt[i])); ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("MacID=%d, AuxAnt_Sum=%d, AuxAnt_Cnt=%d\n", i, dm_fat_tbl->AuxAnt_Sum[i], dm_fat_tbl->AuxAnt_Cnt[i])); ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("MacID=%d, Main_RSSI= %d, Aux_RSSI= %d\n", i, Main_RSSI, Aux_RSSI)); /* 2 Select MaxRSSI for DIG */ LocalMaxRSSI = (Main_RSSI > Aux_RSSI) ? Main_RSSI : Aux_RSSI; if ((LocalMaxRSSI > AntDivMaxRSSI) && (LocalMaxRSSI < 40)) AntDivMaxRSSI = LocalMaxRSSI; if (LocalMaxRSSI > MaxRSSI) MaxRSSI = LocalMaxRSSI; /* 2 Select RX Idle Antenna */ if ((dm_fat_tbl->RxIdleAnt == MAIN_ANT) && (Main_RSSI == 0)) Main_RSSI = Aux_RSSI; else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && (Aux_RSSI == 0)) Aux_RSSI = Main_RSSI; LocalMinRSSI = (Main_RSSI > Aux_RSSI) ? Aux_RSSI : Main_RSSI; if (LocalMinRSSI < MinRSSI) { MinRSSI = LocalMinRSSI; RxIdleAnt = TargetAnt; } /* 2 Select TRX Antenna */ if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) odm_UpdateTxAnt_88E(dm_odm, TargetAnt, i); } dm_fat_tbl->MainAnt_Sum[i] = 0; dm_fat_tbl->AuxAnt_Sum[i] = 0; dm_fat_tbl->MainAnt_Cnt[i] = 0; dm_fat_tbl->AuxAnt_Cnt[i] = 0; } /* 2 Set RX Idle Antenna */ ODM_UpdateRxIdleAnt_88E(dm_odm, RxIdleAnt); pDM_DigTable->AntDiv_RSSI_max = AntDivMaxRSSI; pDM_DigTable->RSSI_max = MaxRSSI; }
static void rtl88eu_dm_hw_ant_div(struct odm_dm_struct *dm_odm) { struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; struct rtw_dig *dig_table = &dm_odm->DM_DigTable; struct sta_info *entry; u32 i, min_rssi = 0xFF, ant_div_max_rssi = 0, max_rssi = 0; u32 local_min_rssi, local_max_rssi; u32 main_rssi, aux_rssi; u8 RxIdleAnt = 0, target_ant = 7; for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { entry = dm_odm->pODM_StaInfo[i]; if (IS_STA_VALID(entry)) { /* 2 Caculate RSSI per Antenna */ main_rssi = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? (dm_fat_tbl->MainAnt_Sum[i]/dm_fat_tbl->MainAnt_Cnt[i]) : 0; aux_rssi = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i]/dm_fat_tbl->AuxAnt_Cnt[i]) : 0; target_ant = (main_rssi >= aux_rssi) ? MAIN_ANT : AUX_ANT; /* 2 Select max_rssi for DIG */ local_max_rssi = (main_rssi > aux_rssi) ? main_rssi : aux_rssi; if ((local_max_rssi > ant_div_max_rssi) && (local_max_rssi < 40)) ant_div_max_rssi = local_max_rssi; if (local_max_rssi > max_rssi) max_rssi = local_max_rssi; /* 2 Select RX Idle Antenna */ if ((dm_fat_tbl->RxIdleAnt == MAIN_ANT) && (main_rssi == 0)) main_rssi = aux_rssi; else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && (aux_rssi == 0)) aux_rssi = main_rssi; local_min_rssi = (main_rssi > aux_rssi) ? aux_rssi : main_rssi; if (local_min_rssi < min_rssi) { min_rssi = local_min_rssi; RxIdleAnt = target_ant; } /* 2 Select TRX Antenna */ if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) update_tx_ant_88eu(dm_odm, target_ant, i); } dm_fat_tbl->MainAnt_Sum[i] = 0; dm_fat_tbl->AuxAnt_Sum[i] = 0; dm_fat_tbl->MainAnt_Cnt[i] = 0; dm_fat_tbl->AuxAnt_Cnt[i] = 0; } /* 2 Set RX Idle Antenna */ rtl88eu_dm_update_rx_idle_ant(dm_odm, RxIdleAnt); dig_table->AntDiv_RSSI_max = ant_div_max_rssi; dig_table->RSSI_max = max_rssi; }
VOID ODM_PathDiversity_8812A( IN PDM_ODM_T pDM_Odm ) { u4Byte i, RssiAvgA=0, RssiAvgB=0, LocalMinRSSI, MinRSSI=0xFF; u1Byte TxRespPath=0, TargetPath; pPATHDIV_T pDM_PathDiv = &pDM_Odm->DM_PathDiv; PSTA_INFO_T pEntry; ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("Odm_PathDiversity_8812A() =>\n")); for (i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++) { pEntry = pDM_Odm->pODM_StaInfo[i]; if(IS_STA_VALID(pEntry)) { //2 Caculate RSSI per Path RssiAvgA = (pDM_PathDiv->PathA_Cnt[i]!=0)?(pDM_PathDiv->PathA_Sum[i]/pDM_PathDiv->PathA_Cnt[i]):0; RssiAvgB = (pDM_PathDiv->PathB_Cnt[i]!=0)?(pDM_PathDiv->PathB_Sum[i]/pDM_PathDiv->PathB_Cnt[i]):0; TargetPath = (RssiAvgA==RssiAvgB)?pDM_PathDiv->RespTxPath:((RssiAvgA>=RssiAvgB)?ODM_RF_PATH_A:ODM_RF_PATH_B); ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("MacID=%d, PathA_Sum=%d, PathA_Cnt=%d\n", i, pDM_PathDiv->PathA_Sum[i], pDM_PathDiv->PathA_Cnt[i])); ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("MacID=%d, PathB_Sum=%d, PathB_Cnt=%d\n",i, pDM_PathDiv->PathB_Sum[i], pDM_PathDiv->PathB_Cnt[i])); ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("MacID=%d, RssiAvgA= %d, RssiAvgB= %d\n", i, RssiAvgA, RssiAvgB)); //2 Select Resp Tx Path LocalMinRSSI = (RssiAvgA>RssiAvgB)?RssiAvgB:RssiAvgA; if(LocalMinRSSI < MinRSSI) { MinRSSI = LocalMinRSSI; TxRespPath = TargetPath; } //2 Select Tx DESC if(TargetPath == ODM_RF_PATH_A) pDM_PathDiv->PathSel[i] = 1; else pDM_PathDiv->PathSel[i] = 2; ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Tx from TxInfo, TargetPath=%s\n", (TargetPath==ODM_RF_PATH_A)?"ODM_RF_PATH_A":"ODM_RF_PATH_B")); ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("pDM_PathDiv->PathSel[%d] = %d\n", i, pDM_PathDiv->PathSel[i])); } pDM_PathDiv->PathA_Cnt[i] = 0; pDM_PathDiv->PathA_Sum[i] = 0; pDM_PathDiv->PathB_Cnt[i] = 0; pDM_PathDiv->PathB_Sum[i] = 0; } //2 Update Tx Path odm_UpdateTxPath_8812A(pDM_Odm, TxRespPath); }
void odm_RefreshRateAdaptiveMask(struct _rtw_dm *pDM_Odm) { u8 i; struct rtl_priv *rtlpriv = pDM_Odm->rtlpriv; struct rate_adaptive *p_ra = &(rtlpriv->ra); PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive; if (rtlpriv->bDriverStopped) { RT_TRACE(rtlpriv, COMP_RATE, DBG_TRACE, "<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"); return; } /* printk("==> %s \n",__FUNCTION__); */ for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i]; if (IS_STA_VALID(pstat)) { if (pstat->rssi_stat.UndecoratedSmoothedPWDB < p_ra->ldpc_thres) { p_ra->use_ldpc = TRUE; pRA->bLowerRtsRate = TRUE; Set_RA_LDPC_8812(pstat, TRUE); /* DbgPrint("RSSI=%d, bUseLdpc = TRUE\n", pHalData->UndecoratedSmoothedPWDB); */ } else if (pstat->rssi_stat.UndecoratedSmoothedPWDB > (p_ra->ldpc_thres-5)) { p_ra->use_ldpc = FALSE; pRA->bLowerRtsRate = FALSE; Set_RA_LDPC_8812(pstat, FALSE); /* DbgPrint("RSSI=%d, bUseLdpc = FALSE\n", pHalData->UndecoratedSmoothedPWDB); */ } if (TRUE == ODM_RAStateCheck(rtlpriv, pstat->rssi_stat.UndecoratedSmoothedPWDB, FALSE , &pstat->rssi_level)) { RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, "RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level); /* printk("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level); */ rtw_hal_update_ra_mask(pstat->rtlpriv, pstat, pstat->rssi_level); } } } }
VOID odm_RefreshRateAdaptiveMaskCE( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; u1Byte i; PADAPTER pAdapter = pDM_Odm->Adapter; PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive; if(pAdapter->bDriverStopped) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n")); return; } if(!pDM_Odm->bUseRAMask) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n")); return; } for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++){ PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i]; if(IS_STA_VALID(pstat) ) { if(IS_MCAST( pstat->hwaddr)) //if(psta->mac_id ==1) continue; if(IS_MCAST( pstat->hwaddr)) continue; if( TRUE == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, FALSE , &pstat->rssi_level) ) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level)); rtw_hal_update_ra_mask(pstat, pstat->rssi_level); } } } }
void odm_RefreshRateAdaptiveMask(struct rtl_priv *rtlpriv) { struct rate_adaptive *p_ra = &(rtlpriv->ra); struct rtl_dm *rtldm = rtl_dm(rtlpriv); u8 i; struct _rtw_hal *pHalData = GET_HAL_DATA(rtlpriv); struct _rtw_dm * pDM_Odm = &(pHalData->odmpriv); if (rtlpriv->bDriverStopped) { RT_TRACE(rtlpriv, COMP_RATE, DBG_TRACE, "<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"); return; } /* printk("==> %s \n",__FUNCTION__); */ for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { struct sta_info *pstat = rtldm->pODM_StaInfo[i]; if (IS_STA_VALID(pstat)) { if (pstat->rssi_stat.UndecoratedSmoothedPWDB < p_ra->ldpc_thres) { p_ra->use_ldpc = true; Set_RA_LDPC_8812(pstat, true); /* DbgPrint("RSSI=%d, bUseLdpc = true\n", pHalData->UndecoratedSmoothedPWDB); */ } else if (pstat->rssi_stat.UndecoratedSmoothedPWDB > (p_ra->ldpc_thres-5)) { p_ra->use_ldpc = false; Set_RA_LDPC_8812(pstat, false); /* DbgPrint("RSSI=%d, bUseLdpc = false\n", pHalData->UndecoratedSmoothedPWDB); */ } if (true == ODM_RAStateCheck(rtlpriv, pstat->rssi_stat.UndecoratedSmoothedPWDB, false , &pstat->rssi_level)) { RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, "RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level); /* printk("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level); */ rtw_hal_update_ra_mask(pstat->rtlpriv, pstat, pstat->rssi_level); } } } }
VOID odm_DynamicTxPowerAP( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; #if (DM_ODM_SUPPORT_TYPE == ODM_AP) //#if ((RTL8192C_SUPPORT==1) || (RTL8192D_SUPPORT==1) || (RTL8188E_SUPPORT==1) || (RTL8812E_SUPPORT==1)) prtl8192cd_priv priv = pDM_Odm->priv; s4Byte i; s2Byte pwr_thd = TX_POWER_NEAR_FIELD_THRESH_AP; if(!priv->pshare->rf_ft_var.tx_pwr_ctrl) return; #if ((RTL8812E_SUPPORT==1) || (RTL8881A_SUPPORT==1)) if (pDM_Odm->SupportICType & (ODM_RTL8812 | ODM_RTL8881A)) pwr_thd = TX_POWER_NEAR_FIELD_THRESH_8812; #endif #if defined(CONFIG_RTL_92D_SUPPORT) || defined(CONFIG_RTL_92C_SUPPORT) if(CHIP_VER_92X_SERIES(priv)) { #ifdef HIGH_POWER_EXT_PA if(pDM_Odm->ExtPA) tx_power_control(priv); #endif } #endif /* * Check if station is near by to use lower tx power */ if ((priv->up_time % 3) == 0 ) { int disable_pwr_ctrl = ((pDM_Odm->FalseAlmCnt.Cnt_all > 1000 ) || ((pDM_Odm->FalseAlmCnt.Cnt_all > 300 ) && ((RTL_R8(0xc50) & 0x7f) >= 0x32))) ? 1 : 0; for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++){ PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i]; if(IS_STA_VALID(pstat) ) { if(disable_pwr_ctrl) pstat->hp_level = 0; else if ((pstat->hp_level == 0) && (pstat->rssi > pwr_thd)) pstat->hp_level = 1; else if ((pstat->hp_level == 1) && (pstat->rssi < (pwr_thd-8))) pstat->hp_level = 0; } } #if defined(CONFIG_WLAN_HAL_8192EE) if (GET_CHIP_VER(priv) == VERSION_8192E) { if( !disable_pwr_ctrl && (pDM_Odm->RSSI_Min != 0xff) ) { if(pDM_Odm->RSSI_Min > pwr_thd) RRSR_power_control_11n(priv, 1 ); else if(pDM_Odm->RSSI_Min < (pwr_thd-8)) RRSR_power_control_11n(priv, 0 ); } else { RRSR_power_control_11n(priv, 0 ); } } #endif } //#endif #endif }
VOID odm_SetNextMACAddrTarget( IN PDM_ODM_T pDM_Odm ) { pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable; PSTA_INFO_T pEntry; //u1Byte Bssid[6]; u4Byte value32, i; // //2012.03.26 LukeLee: The MAC address is changed according to MACID in turn // ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_SetNextMACAddrTarget() ==>\n")); if(pDM_Odm->bLinked) { for (i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++) { if((pDM_FatTable->TrainIdx+1) == ODM_ASSOCIATE_ENTRY_NUM) pDM_FatTable->TrainIdx = 0; else pDM_FatTable->TrainIdx++; pEntry = pDM_Odm->pODM_StaInfo[pDM_FatTable->TrainIdx]; if(IS_STA_VALID(pEntry)) { //Match MAC ADDR #if (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) value32 = (pEntry->hwaddr[5]<<8)|pEntry->hwaddr[4]; #else value32 = (pEntry->MacAddr[5]<<8)|pEntry->MacAddr[4]; #endif ODM_SetMACReg(pDM_Odm, 0x7b4, 0xFFFF, value32); #if (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) value32 = (pEntry->hwaddr[3]<<24)|(pEntry->hwaddr[2]<<16) |(pEntry->hwaddr[1]<<8) |pEntry->hwaddr[0]; #else value32 = (pEntry->MacAddr[3]<<24)|(pEntry->MacAddr[2]<<16) |(pEntry->MacAddr[1]<<8) |pEntry->MacAddr[0]; #endif ODM_SetMACReg(pDM_Odm, 0x7b0, bMaskDWord, value32); ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("pDM_FatTable->TrainIdx=%d\n",pDM_FatTable->TrainIdx)); #if (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL)) ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Training MAC Addr = %x:%x:%x:%x:%x:%x\n", pEntry->hwaddr[5],pEntry->hwaddr[4],pEntry->hwaddr[3],pEntry->hwaddr[2],pEntry->hwaddr[1],pEntry->hwaddr[0])); #else ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Training MAC Addr = %x:%x:%x:%x:%x:%x\n", pEntry->MacAddr[5],pEntry->MacAddr[4],pEntry->MacAddr[3],pEntry->MacAddr[2],pEntry->MacAddr[1],pEntry->MacAddr[0])); #endif break; } } } #if 0 // //2012.03.26 LukeLee: This should be removed later, the MAC address is changed according to MACID in turn // #if( DM_ODM_SUPPORT_TYPE & ODM_MP) { PADAPTER Adapter = pDM_Odm->Adapter; PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; for (i=0; i<6; i++) { Bssid[i] = pMgntInfo->Bssid[i]; //DbgPrint("Bssid[%d]=%x\n", i, Bssid[i]); } } #endif //odm_SetNextMACAddrTarget(pDM_Odm); //1 Select MAC Address Filter for (i=0; i<6; i++) { if(Bssid[i] != pDM_FatTable->Bssid[i]) { bMatchBSSID = FALSE; break; } } if(bMatchBSSID == FALSE) { //Match MAC ADDR value32 = (Bssid[5]<<8)|Bssid[4]; ODM_SetMACReg(pDM_Odm, 0x7b4, 0xFFFF, value32); value32 = (Bssid[3]<<24)|(Bssid[2]<<16) |(Bssid[1]<<8) |Bssid[0]; ODM_SetMACReg(pDM_Odm, 0x7b0, bMaskDWord, value32); } return bMatchBSSID; #endif }
VOID odm_HWAntDiv( IN PDM_ODM_T pDM_Odm ) { u4Byte i, MinRSSI=0xFF, AntDivMaxRSSI=0, MaxRSSI=0, LocalMinRSSI, LocalMaxRSSI; u4Byte Main_RSSI, Aux_RSSI; u1Byte RxIdleAnt=0, TargetAnt=7; pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable; pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; BOOLEAN bMatchBSSID; BOOLEAN bPktFilterMacth = FALSE; PSTA_INFO_T pEntry; for (i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++) { pEntry = pDM_Odm->pODM_StaInfo[i]; if(IS_STA_VALID(pEntry)) { //2 Caculate RSSI per Antenna Main_RSSI = (pDM_FatTable->MainAnt_Cnt[i]!=0)?(pDM_FatTable->MainAnt_Sum[i]/pDM_FatTable->MainAnt_Cnt[i]):0; Aux_RSSI = (pDM_FatTable->AuxAnt_Cnt[i]!=0)?(pDM_FatTable->AuxAnt_Sum[i]/pDM_FatTable->AuxAnt_Cnt[i]):0; TargetAnt = (Main_RSSI>=Aux_RSSI)?MAIN_ANT:AUX_ANT; ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("MacID=%d, MainAnt_Sum=%d, MainAnt_Cnt=%d\n", i, pDM_FatTable->MainAnt_Sum[i], pDM_FatTable->MainAnt_Cnt[i])); ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("MacID=%d, AuxAnt_Sum=%d, AuxAnt_Cnt=%d\n",i, pDM_FatTable->AuxAnt_Sum[i], pDM_FatTable->AuxAnt_Cnt[i])); ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("MacID=%d, Main_RSSI= %d, Aux_RSSI= %d\n", i, Main_RSSI, Aux_RSSI)); //2 Select MaxRSSI for DIG LocalMaxRSSI = (Main_RSSI>Aux_RSSI)?Main_RSSI:Aux_RSSI; if((LocalMaxRSSI > AntDivMaxRSSI) && (LocalMaxRSSI < 40)) AntDivMaxRSSI = LocalMaxRSSI; if(LocalMaxRSSI > MaxRSSI) MaxRSSI = LocalMaxRSSI; //2 Select RX Idle Antenna if((pDM_FatTable->RxIdleAnt == MAIN_ANT) && (Main_RSSI == 0)) Main_RSSI = Aux_RSSI; else if((pDM_FatTable->RxIdleAnt == AUX_ANT) && (Aux_RSSI == 0)) Aux_RSSI = Main_RSSI; LocalMinRSSI = (Main_RSSI>Aux_RSSI)?Aux_RSSI:Main_RSSI; if(LocalMinRSSI < MinRSSI) { MinRSSI = LocalMinRSSI; RxIdleAnt = TargetAnt; } #if TX_BY_REG #else //2 Select TRX Antenna if(pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) odm_UpdateTxAnt_88E(pDM_Odm, TargetAnt, i); #endif } pDM_FatTable->MainAnt_Sum[i] = 0; pDM_FatTable->AuxAnt_Sum[i] = 0; pDM_FatTable->MainAnt_Cnt[i] = 0; pDM_FatTable->AuxAnt_Cnt[i] = 0; } //2 Set RX Idle Antenna ODM_UpdateRxIdleAnt_88E(pDM_Odm, RxIdleAnt); pDM_DigTable->AntDiv_RSSI_max = AntDivMaxRSSI; pDM_DigTable->RSSI_max = MaxRSSI; }
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
uint32_t ODM_Get_Rate_Bitmap(struct _rtw_dm *pDM_Odm, uint32_t macid, uint32_t ra_mask, u8 rssi_level) { struct rtl_priv *rtlpriv = pDM_Odm->rtlpriv; struct rtl_hal *rtlhal = rtl_hal(rtlpriv); struct sta_info *pEntry; uint32_t rate_bitmap = 0; u8 WirelessMode; /* u8 WirelessMode =*(pDM_Odm->pWirelessMode); */ pEntry = pDM_Odm->pODM_StaInfo[macid]; if (!IS_STA_VALID(pEntry)) return ra_mask; WirelessMode = pEntry->wireless_mode; switch (WirelessMode) { case WIRELESS_MODE_B: if (ra_mask & 0x0000000c) /* 11M or 5.5M enable */ rate_bitmap = 0x0000000d; else rate_bitmap = 0x0000000f; break; case WIRELESS_MODE_G: case WIRELESS_MODE_A: if (rssi_level == DM_RATR_STA_HIGH) rate_bitmap = 0x00000f00; else rate_bitmap = 0x00000ff0; break; case WIRELESS_MODE_B | WIRELESS_MODE_G: if (rssi_level == DM_RATR_STA_HIGH) rate_bitmap = 0x00000f00; else if (rssi_level == DM_RATR_STA_MIDDLE) rate_bitmap = 0x00000ff0; else rate_bitmap = 0x00000ff5; break; case WIRELESS_MODE_B | WIRELESS_MODE_G | WIRELESS_MODE_N_24G: case WIRELESS_MODE_B | WIRELESS_MODE_N_24G: case WIRELESS_MODE_A | WIRELESS_MODE_N_5G: if (pDM_Odm->rtlpriv->phy.rf_type == ODM_1T2R || pDM_Odm->rtlpriv->phy.rf_type == ODM_1T1R) { if (rssi_level == DM_RATR_STA_HIGH) { rate_bitmap = 0x000f0000; } else if (rssi_level == DM_RATR_STA_MIDDLE) { rate_bitmap = 0x000ff000; } else { if (rtlpriv->phy.current_chan_bw == ODM_BW40M) rate_bitmap = 0x000ff015; else rate_bitmap = 0x000ff005; } } else { if (rssi_level == DM_RATR_STA_HIGH) { rate_bitmap = 0x0f8f0000; } else if (rssi_level == DM_RATR_STA_MIDDLE) { rate_bitmap = 0x0f8ff000; } else { if (rtlpriv->phy.current_chan_bw == ODM_BW40M) rate_bitmap = 0x0f8ff015; else rate_bitmap = 0x0f8ff005; } } break; case WIRELESS_MODE_AC_5G | WIRELESS_MODE_A: case WIRELESS_MODE_AC_5G | WIRELESS_MODE_G: if (pDM_Odm->rtlpriv->phy.rf_type == RF_1T1R) { if (IS_HARDWARE_TYPE_8811AU(rtlhal) || (IS_HARDWARE_TYPE_8812AU(rtlhal) && IS_NORMAL_CHIP(rtlhal->version))) { if (IS_HARDWARE_TYPE_8821U(rtlhal) && (rtlpriv->phy.current_channel >= 149)) { if (rssi_level == 1) /* add by Gary for ac-series */ rate_bitmap = 0x001f8000; else if (rssi_level == 2) rate_bitmap = 0x001ff000; else rate_bitmap = 0x001ff010; } else { if (rssi_level == 1) /* add by Gary for ac-series */ rate_bitmap = 0x003f8000; else if (rssi_level == 2) rate_bitmap = 0x003ff000; else rate_bitmap = 0x003ff010; } } else { rate_bitmap = 0x000ff010; } } else { if (IS_NORMAL_CHIP(rtlhal->version)) { if (rssi_level == 1) /* add by Gary for ac-series */ rate_bitmap = 0xfe3f8000; /* VHT 2SS MCS3~9 */ else if (rssi_level == 2) rate_bitmap = 0xfffff000; /* VHT 2SS MCS0~9 */ else rate_bitmap = 0xfffff010; /* All */ } else rate_bitmap = 0x3fcff010; } break; default: if (pDM_Odm->rtlpriv->phy.rf_type == RF_1T2R) rate_bitmap = 0x000fffff; else rate_bitmap = 0x0fffffff; break; } /* printk("%s ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n",__FUNCTION__,rssi_level,WirelessMode,rate_bitmap); */ RT_TRACE(rtlpriv, COMP_RATE, DBG_LOUD, " ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n", rssi_level, WirelessMode, rate_bitmap); return (ra_mask&rate_bitmap); }
u4Byte ODM_Get_Rate_Bitmap( IN PVOID pDM_VOID, IN u4Byte macid, IN u4Byte ra_mask, IN u1Byte rssi_level ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PSTA_INFO_T pEntry; u4Byte rate_bitmap = 0; u1Byte WirelessMode; pEntry = pDM_Odm->pODM_StaInfo[macid]; if(!IS_STA_VALID(pEntry)) return ra_mask; WirelessMode = pEntry->wireless_mode; switch(WirelessMode) { case ODM_WM_B: if(ra_mask & 0x0000000c) //11M or 5.5M enable rate_bitmap = 0x0000000d; else rate_bitmap = 0x0000000f; break; case (ODM_WM_G): case (ODM_WM_A): if(rssi_level == DM_RATR_STA_HIGH) rate_bitmap = 0x00000f00; else rate_bitmap = 0x00000ff0; break; case (ODM_WM_B|ODM_WM_G): if(rssi_level == DM_RATR_STA_HIGH) rate_bitmap = 0x00000f00; else if(rssi_level == DM_RATR_STA_MIDDLE) rate_bitmap = 0x00000ff0; else rate_bitmap = 0x00000ff5; break; case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G) : case (ODM_WM_B|ODM_WM_N24G) : case (ODM_WM_G|ODM_WM_N24G) : case (ODM_WM_A|ODM_WM_N5G) : { if ( pDM_Odm->RFType == ODM_1T2R ||pDM_Odm->RFType == ODM_1T1R) { if(rssi_level == DM_RATR_STA_HIGH) { rate_bitmap = 0x000f0000; } else if(rssi_level == DM_RATR_STA_MIDDLE) { rate_bitmap = 0x000ff000; } else{ if (*(pDM_Odm->pBandWidth) == ODM_BW40M) rate_bitmap = 0x000ff015; else rate_bitmap = 0x000ff005; } } else { if(rssi_level == DM_RATR_STA_HIGH) { rate_bitmap = 0x0f8f0000; } else if(rssi_level == DM_RATR_STA_MIDDLE) { rate_bitmap = 0x0f8ff000; } else { if (*(pDM_Odm->pBandWidth) == ODM_BW40M) rate_bitmap = 0x0f8ff015; else rate_bitmap = 0x0f8ff005; } } } break; case (ODM_WM_AC|ODM_WM_G): if(rssi_level == 1) rate_bitmap = 0xfc3f0000; else if(rssi_level == 2) rate_bitmap = 0xfffff000; else rate_bitmap = 0xffffffff; break; case (ODM_WM_AC|ODM_WM_A): if (pDM_Odm->RFType == RF_1T1R) { if(rssi_level == 1) // add by Gary for ac-series rate_bitmap = 0x003f8000; else if (rssi_level == 2) rate_bitmap = 0x003ff000; else rate_bitmap = 0x003ff010; } else { if(rssi_level == 1) // add by Gary for ac-series rate_bitmap = 0xfe3f8000; // VHT 2SS MCS3~9 else if (rssi_level == 2) rate_bitmap = 0xfffff000; // VHT 2SS MCS0~9 else rate_bitmap = 0xfffff010; // All } break; default: if(pDM_Odm->RFType == RF_1T2R) rate_bitmap = 0x000fffff; else rate_bitmap = 0x0fffffff; break; } ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n",rssi_level,WirelessMode,rate_bitmap)); return (ra_mask&rate_bitmap); }
VOID odm_RSSIMonitorCheckCE( IN PVOID pDM_VOID ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; PADAPTER Adapter = pDM_Odm->Adapter; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &pHalData->dmpriv; struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(Adapter); int i; int tmpEntryMaxPWDB=0, tmpEntryMinPWDB=0xff; u8 sta_cnt=0; u32 UL_DL_STATE = 0, STBC_TX = 0, TxBF_EN = 0; u32 PWDB_rssi[NUM_STA]={0};//[0~15]:MACID, [16~31]:PWDB_rssi BOOLEAN FirstConnect = FALSE; pRA_T pRA_Table = &pDM_Odm->DM_RA_Table; if(pDM_Odm->bLinked != _TRUE) return; FirstConnect = (pDM_Odm->bLinked) && (pRA_Table->firstconnect == FALSE); pRA_Table->firstconnect = pDM_Odm->bLinked; { struct sta_info *psta; for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++) { if (IS_STA_VALID(psta = pDM_Odm->pODM_StaInfo[i])) { if(IS_MCAST( psta->hwaddr)) //if(psta->mac_id ==1) continue; if(psta->rssi_stat.UndecoratedSmoothedPWDB == (-1)) continue; if(psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB) tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; if(psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB) tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; if(psta->rssi_stat.UndecoratedSmoothedPWDB != (-1)) { #ifdef CONFIG_80211N_HT if(pDM_Odm->SupportICType == ODM_RTL8192E || pDM_Odm->SupportICType == ODM_RTL8812) { #ifdef CONFIG_BEAMFORMING BEAMFORMING_CAP Beamform_cap = beamforming_get_entry_beam_cap_by_mac_id(&Adapter->mlmepriv, psta->mac_id); if(Beamform_cap & (BEAMFORMER_CAP_HT_EXPLICIT |BEAMFORMER_CAP_VHT_SU)) TxBF_EN = 1; else TxBF_EN = 0; if (TxBF_EN) { STBC_TX = 0; } else #endif { #ifdef CONFIG_80211AC_VHT if(IsSupportedVHT(psta->wireless_mode)) STBC_TX = TEST_FLAG(psta->vhtpriv.stbc_cap, STBC_VHT_ENABLE_TX); else #endif STBC_TX = TEST_FLAG(psta->htpriv.stbc_cap, STBC_HT_ENABLE_TX); } } #endif if(pDM_Odm->SupportICType == ODM_RTL8192D) PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16) | ((Adapter->stapriv.asoc_sta_count+1) << 8)); else if ((pDM_Odm->SupportICType == ODM_RTL8192E)||(pDM_Odm->SupportICType == ODM_RTL8812)||(pDM_Odm->SupportICType == ODM_RTL8821)) PWDB_rssi[sta_cnt++] = (((u8)(psta->mac_id&0xFF)) | ((psta->rssi_stat.UndecoratedSmoothedPWDB&0x7F)<<16) |(STBC_TX << 25) | (FirstConnect << 29) | (TxBF_EN << 30)); else PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16) ); } } } for(i=0; i< sta_cnt; i++) { if(PWDB_rssi[i] != (0)){ if(pHalData->fw_ractrl == _TRUE)// Report every sta's RSSI to FW { if(pDM_Odm->SupportICType == ODM_RTL8723B){ rtl8723b_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i])); } } } } } if(tmpEntryMaxPWDB != 0) // If associated entry is found { pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB; } else { pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0; } if(tmpEntryMinPWDB != 0xff) // If associated entry is found { pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB; } else { pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0; } FindMinimumRSSI(Adapter);//get pdmpriv->MinUndecoratedPWDBForDM pDM_Odm->RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM; }