/* ======================================================================== Routine Description: Reset alarm function. Arguments: pAd - WLAN control block pointer Return Value: None Note: ======================================================================== */ VOID QBSS_LoadAlarmReset( IN RTMP_ADAPTER *pAd) { #ifdef QLOAD_FUNC_BUSY_TIME_ALARM pAd->FlgQloadAlarm = FALSE; pAd->QloadAlarmDuration = 0; pAd->QloadAlarmNumber = 0; pAd->FlgQloadAlarmIsSuspended = FALSE; QBSS_LoadAlarmBusyTimeThresholdReset(pAd, pAd->CommonCfg.BeaconPeriod); #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ } /* End of QBSS_LoadAlarmReset */
/* ======================================================================== Routine Description: Reset alarm function. Arguments: pAd - WLAN control block pointer Return Value: None Note: ======================================================================== */ VOID QBSS_LoadAlarmReset( IN struct rtmp_adapter *pAd) { #ifdef QLOAD_FUNC_BUSY_TIME_ALARM pAd->FlgQloadAlarm = false; pAd->QloadAlarmDuration = 0; pAd->QloadAlarmNumber = 0; pAd->FlgQloadAlarmIsSuspended = false; QBSS_LoadAlarmBusyTimeThresholdReset(pAd, pAd->CommonCfg.BeaconPeriod); #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ }
/* ======================================================================== 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->FlgQloadEnable == 0) return; /* End of if */ /* calculate new time period if needed */ if ((UpTime > 0) && (pAd->QloadUpTimeLast > 0) && (UpTime > pAd->QloadUpTimeLast)) { /* re-calculate time period */ TimePeriod = (UINT32)(UpTime - pAd->QloadUpTimeLast); /* translate to mini-second */ TimePeriod = (TimePeriod*1000)/OS_HZ; #ifdef QLOAD_FUNC_BUSY_TIME_ALARM /* re-calculate QloadBusyTimeThreshold */ if (TimePeriod != pAd->QloadTimePeriodLast) QBSS_LoadAlarmBusyTimeThresholdReset(pAd, TimePeriod); /* End of if */ pAd->QloadTimePeriodLast = TimePeriod; #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ } /* End of if */ /* update up time */ pAd->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 */ RTMP_IO_READ32(pAd, CH_BUSY_STA_SEC, &BusyTime); pAd->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; /* End of if */ pAd->QloadBusyCountSec[BusyTimeId] ++; #endif /* QLOAD_FUNC_BUSY_TIME_STATS */ #ifdef QLOAD_FUNC_BUSY_TIME_ALARM if ((pAd->FlgQloadAlarmIsSuspended == FALSE) && (pAd->QloadAlarmBusyTimeThreshold > 0)) { /* Alarm is not suspended and is enabled */ if ((pAd->QloadBusyTimeThreshold != 0) && (BusyTime >= pAd->QloadBusyTimeThreshold)) { FlgIsBusyOverThreshold = TRUE; } /* End of if */ } /* End of if */ #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ } /* End of if */
/* ======================================================================== 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 struct rtmp_adapter *pAd, IN ULONG UpTime) { uint32_t ChanUtilNu, ChanUtilDe; uint32_t BusyTime = 0; uint32_t BusyTimeId; uint32_t TimePeriod = pAd->CommonCfg.BeaconPeriod; #ifdef QLOAD_FUNC_BUSY_TIME_ALARM bool FlgIsBusyOverThreshold = false; bool FlgIsAlarmNeeded = false; #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ /* check whether channel busy time calculation is enabled */ if ((pAd->FlgQloadEnable == 0) || (pAd->FlgQloadAlarmIsSuspended == true)) return; /* calculate new time period if needed */ if ((UpTime > 0) && (pAd->QloadUpTimeLast > 0) && (UpTime > pAd->QloadUpTimeLast)) { /* re-calculate time period */ TimePeriod = (uint32_t)(UpTime - pAd->QloadUpTimeLast); /* translate to mini-second */ TimePeriod = (TimePeriod*1000)/OS_HZ; #ifdef QLOAD_FUNC_BUSY_TIME_ALARM /* re-calculate QloadBusyTimeThreshold */ if (TimePeriod != pAd->QloadTimePeriodLast) QBSS_LoadAlarmBusyTimeThresholdReset(pAd, TimePeriod); pAd->QloadTimePeriodLast = TimePeriod; #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ } /* update up time */ pAd->QloadUpTimeLast = UpTime; /* do busy time statistics */ 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 = mt76u_reg_read(pAd, CH_BUSY_STA_SEC); pAd->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->QloadBusyCountSec[BusyTimeId] ++; #endif /* QLOAD_FUNC_BUSY_TIME_STATS */ #ifdef QLOAD_FUNC_BUSY_TIME_ALARM if ((pAd->FlgQloadAlarmIsSuspended == false) && (pAd->QloadAlarmBusyTimeThreshold > 0)) { /* Alarm is not suspended and is enabled */ if ((pAd->QloadBusyTimeThreshold != 0) && (BusyTime >= pAd->QloadBusyTimeThreshold)) { FlgIsBusyOverThreshold = true; } } #endif /* QLOAD_FUNC_BUSY_TIME_ALARM */ }