VOID UpdateChannelInfo( IN PRTMP_ADAPTER pAd, IN int ch_index, IN ChannelSel_Alg Alg) { if(pAd->pChannelInfo != NULL) { UINT32 BusyTime; if (Alg == ChannelAlgCCA) { UINT32 cca_cnt = AsicGetCCACnt(pAd); pAd->RalinkCounters.OneSecFalseCCACnt += cca_cnt; pAd->pChannelInfo->FalseCCA[ch_index] = cca_cnt; } /* do busy time statistics for primary channel scan time 400ms, beacon interval 100 ms */ BusyTime = AsicGetChBusyCnt(pAd, 0); //#ifdef AP_QLOAD_SUPPORT pAd->pChannelInfo->chanbusytime[ch_index] = (BusyTime * 100) / AUTO_CHANNEL_SEL_TIMEOUT; //#endif /* AP_QLOAD_SUPPORT */ } else MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_ERROR, ("pAd->pChannelInfo equal NULL.\n")); return; }
/* ========================================================================== Description: This routine is called at initialization. It returns a channel number that complies to regulation domain and less interference with current enviornment. Return: ch - channel number that NOTE: The retruned channel number is guaranteed to comply to current regulation domain that recorded in pAd->CommonCfg.CountryRegion Usage: 1.) iwpriv ra0 set AutoChannelSel=1 Ues the number of AP and inference status to choose 2.) iwpriv ra0 set AutoChannelSel=2 Ues the False CCA count and Rssi to choose ========================================================================== */ UCHAR APAutoSelectChannel(RTMP_ADAPTER *pAd, ChannelSel_Alg Alg) { UCHAR ch = 0, i; UINT32 BusyTime; /* passive scan channel 1-14. collect statistics */ /* In the autochannel select case. AP didn't get channel yet. So have no way to determine which Band AP used by channel number. */ /* Init some structures before doing AutoChannelSelect() */ APAutoChannelInit(pAd); if (( Alg == ChannelAlgRandom ) && (pAd->pChannelInfo->IsABand == TRUE)) { /*for Dfs */ ch = SelectClearChannelRandom(pAd); } else { #ifdef MICROWAVE_OVEN_SUPPORT pAd->CommonCfg.MO_Cfg.bEnable = FALSE; AsicMeasureFalseCCA(pAd); #endif /* MICROWAVE_OVEN_SUPPORT */ /*find RSSI in each channel */ for (i=0; i<pAd->ChannelListNum; i++) { ULONG wait_time = 200; /* wait for 200 ms at each channel. */ AsicSwitchChannel(pAd, pAd->ChannelList[i].Channel, TRUE); AsicLockChannel(pAd, pAd->ChannelList[i].Channel);/*do nothing */ pAd->ApCfg.current_channel_index = i; pAd->ApCfg.AutoChannel_Channel = pAd->ChannelList[i].Channel; /* Read-Clear reset Channel busy time counter */ BusyTime = AsicGetChBusyCnt(pAd, 0); #ifdef AP_QLOAD_SUPPORT /* QLOAD ALARM, ever alarm from QLOAD module */ if (QLOAD_DOES_ALARM_OCCUR(pAd)) wait_time = 400; #endif /* AP_QLOAD_SUPPORT */ OS_WAIT(wait_time); UpdateChannelInfo(pAd, i,Alg); } ch = SelectBestChannel(pAd, Alg); } return ch; }
VOID APAutoChannelInit(RTMP_ADAPTER *pAd) { UINT32 BusyTime; /* reset bss table */ AutoChBssTableReset(pAd); /* clear Channel Info */ ChannelInfoReset(pAd); /* init pAd->pChannelInfo->IsABand */ CheckPhyModeIsABand(pAd); pAd->ApCfg.current_channel_index = 0; /* read clear for primary channel */ BusyTime = AsicGetChBusyCnt(pAd, 0); }
/* ======================================================================== Routine Description: Update Channel Utilization. Arguments: pAd - WLAN control block pointer UpTime - current up time Return Value: None Note: UpTime is used in QLOAD_FUNC_BUSY_TIME_STATS & QLOAD_FUNC_BUSY_TIME_ALARM If UpTime != 0, it means that the time period calling the function maybe not TBTT so we need to re-calculate the time period. If you call the function in kernel thread, the time period sometimes will not accurate due to kernel thread is not real-time, so we need to recalculate the time period. ======================================================================== */ VOID QBSS_LoadUpdate( IN RTMP_ADAPTER *pAd, IN ULONG UpTime) { UINT32 ChanUtilNu, ChanUtilDe; UINT32 BusyTime = 0; UINT32 BusyTimeId; UINT32 TimePeriod = pAd->CommonCfg.BeaconPeriod; #ifdef QLOAD_FUNC_BUSY_TIME_ALARM BOOLEAN FlgIsBusyOverThreshold = FALSE; BOOLEAN FlgIsAlarmNeeded = FALSE; #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ /* check whether channel busy time calculation is enabled */ if ((pAd->phy_ctrl.FlgQloadEnable == 0) || (pAd->phy_ctrl.FlgQloadAlarmIsSuspended == TRUE)) return; /* calculate new time period if needed */ if ((UpTime > 0) && (pAd->phy_ctrl.QloadUpTimeLast > 0) && (UpTime > pAd->phy_ctrl.QloadUpTimeLast)) { /* re-calculate time period */ TimePeriod = (UINT32)(UpTime - pAd->phy_ctrl.QloadUpTimeLast); /* translate to mini-second */ TimePeriod = (TimePeriod*1000)/OS_HZ; #ifdef QLOAD_FUNC_BUSY_TIME_ALARM /* re-calculate QloadBusyTimeThreshold */ if (TimePeriod != pAd->phy_ctrl.QloadTimePeriodLast) QBSS_LoadAlarmBusyTimeThresholdReset(pAd, TimePeriod); pAd->phy_ctrl.QloadTimePeriodLast = TimePeriod; #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ } /* update up time */ pAd->phy_ctrl.QloadUpTimeLast = UpTime; /* do busy time statistics */ #ifdef DOT11_N_SUPPORT if ((pAd->CommonCfg.AddHTInfo.AddHtInfo.ExtChanOffset != 0) && (pAd->CommonCfg.AddHTInfo.AddHtInfo.RecomWidth != 0)) { /* in 20MHz, no need to check busy time of secondary channel */ BusyTime = AsicGetChBusyCnt(pAd, 1); pAd->phy_ctrl.QloadLatestChannelBusyTimeSec = BusyTime; #ifdef QLOAD_FUNC_BUSY_TIME_STATS BusyTimeId = BusyTime >> 10; /* translate us to ms */ /* ex:95ms, 95*20/100 = 19 */ BusyTimeId = (BusyTimeId*QLOAD_BUSY_INTERVALS)/TimePeriod; if (BusyTimeId >= QLOAD_BUSY_INTERVALS) BusyTimeId = QLOAD_BUSY_INTERVALS - 1; pAd->phy_ctrl.QloadBusyCountSec[BusyTimeId] ++; #endif /* QLOAD_FUNC_BUSY_TIME_STATS */ #ifdef QLOAD_FUNC_BUSY_TIME_ALARM if ((pAd->phy_ctrl.FlgQloadAlarmIsSuspended == FALSE) && (pAd->phy_ctrl.QloadAlarmBusyTimeThreshold > 0)) { /* Alarm is not suspended and is enabled */ if ((pAd->phy_ctrl.QloadBusyTimeThreshold != 0) && (BusyTime >= pAd->phy_ctrl.QloadBusyTimeThreshold)) { FlgIsBusyOverThreshold = TRUE; } } #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ }
(pAd->phy_ctrl.QloadAlarmBusyTimeThreshold > 0)) { /* Alarm is not suspended and is enabled */ if ((pAd->phy_ctrl.QloadBusyTimeThreshold != 0) && (BusyTime >= pAd->phy_ctrl.QloadBusyTimeThreshold)) { FlgIsBusyOverThreshold = TRUE; } } #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ } #endif /* DOT11_N_SUPPORT */ /* do busy time statistics for primary channel */ BusyTime = AsicGetChBusyCnt(pAd, 0); pAd->phy_ctrl.QloadLatestChannelBusyTimePri = BusyTime; #ifdef QLOAD_FUNC_BUSY_TIME_STATS BusyTimeId = BusyTime >> 10; /* translate us to ms */ /* ex:95ms, 95*20/100 = 19 */ BusyTimeId = (BusyTimeId*QLOAD_BUSY_INTERVALS)/TimePeriod; if (BusyTimeId >= QLOAD_BUSY_INTERVALS) BusyTimeId = QLOAD_BUSY_INTERVALS - 1; pAd->phy_ctrl.QloadBusyCountPri[BusyTimeId] ++; #endif /* QLOAD_FUNC_BUSY_TIME_STATS */ #ifdef QLOAD_FUNC_BUSY_TIME_ALARM