X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2F5gnrsch%2Fsch_tmr.c;h=1a7fb3f984d27c3f4b6774afb5e537b89731b387;hb=e96cb439cd4a7a6f55e3fab7caed978e38bd62b4;hp=e880db0acdcc2aef2e9b83fce7b14ff6788183f3;hpb=d75d1b078091768f45b83f2a745a25917e03b39d;p=o-du%2Fl2.git diff --git a/src/5gnrsch/sch_tmr.c b/src/5gnrsch/sch_tmr.c index e880db0ac..1a7fb3f98 100644 --- a/src/5gnrsch/sch_tmr.c +++ b/src/5gnrsch/sch_tmr.c @@ -21,6 +21,164 @@ #include "lrg.x" #include "mac_sch_interface.h" #include "sch.h" +#include "sch_tmr.h" + +/** + * @brief Handler to check if the timer is running + * + * @param[in] cb Control block depending on the type of the timer event. + * @param[in] tmrEvnt Timer event to be started + * + * @return Bool indicating whether the timer is running or not + * -# ROK + * -# RFAILED +*/ +bool schChkTmr(PTR cb, int16_t tmrEvnt) +{ + switch (tmrEvnt) + { + case EVENT_STATISTICS_TMR: + { + if(((SchStatsGrp *)cb)->periodTimer.tmrEvnt == EVENT_STATISTICS_TMR) + { + DU_LOG("\nDEBUG --> SCH : schChkTmr: Timer Evnt [%d] already running", tmrEvnt); + return TRUE; + } + break; + } + default: + { + DU_LOG("\nERROR --> SCH : schChkTmr: Invalid tmr Evnt [%d]", tmrEvnt); + } + } + return FALSE; +} + +/** + * @brief Handler to start timer + * + * @param[in] cb Control block depending on the type of the timer event. + * @param[in] tmrEvnt Timer event to be started + * + * @return Void +*/ +void schStartTmr(SchCb *gCb, PTR cb, int16_t tmrEvnt, uint16_t timerValue) +{ + SchStatsGrp *statsGrp = NULLP; + CmTmrArg arg; + + arg.wait = 0; + +#ifdef DEBUG_PRINT + DU_LOG("\nDEBUG --> SCH : Starting Timer Event [%d] with Wait Time [%d] ms", \ + tmrEvnt, timerValue); +#endif + + switch (tmrEvnt) + { + case EVENT_STATISTICS_TMR: + { + statsGrp = ((SchStatsGrp *)cb); + TMR_CALCUATE_WAIT(arg.wait, timerValue, gCb->schTimersInfo.tmrRes); + + arg.timers = &statsGrp->periodTimer; + arg.max = MAX_NUM_TMR_PER_STATS_GRP; + break; + } + + default: + { + DU_LOG("\nERROR --> SCH : schStartTmr: Invalid tmr Evnt [%d]", tmrEvnt); + } + } + + if(arg.wait != 0) + { + arg.tqCp = &(gCb->schTimersInfo.tmrTqCp); + arg.tq = gCb->schTimersInfo.tmrTq; + arg.cb = cb; + arg.evnt = tmrEvnt; + arg.tNum = 0; + + cmPlcCbTq(&arg); + } + + return; +} + +/** + * @brief Handler to stop a timer + * + * @param[in] cb Control block depending on the type of the timer event. + * @param[in] tmrType Timer event to be started + * + * @return Void +*/ +void schStopTmr(SchCb *gCb, PTR cb, uint8_t tmrType) +{ + CmTmrArg arg; + + arg.timers = NULLP; + +#ifdef DEBUG_PRINT + DU_LOG("\nDEBUG --> SCH : Stopping Timer Event [%d]", tmrType); +#endif + + switch (tmrType) + { + case EVENT_STATISTICS_TMR: + { + arg.timers = &((SchStatsGrp *)cb)->periodTimer; + arg.max = MAX_NUM_TMR_PER_STATS_GRP; + break; + } + + default: + { + DU_LOG("\nERROR --> SCH : schStopTmr: Invalid tmr Evnt[%d]", tmrType); + break; + } + } + + if (tmrType != TMR0) + { + arg.tqCp = &gCb->schTimersInfo.tmrTqCp; + arg.tq = gCb->schTimersInfo.tmrTq; + arg.cb = cb; + arg.evnt = tmrType; + arg.wait = 0; + arg.tNum = 0; + cmRmvCbTq(&arg); + } + + return; +} + +/** + * @brief Handler for Statistics group timer expiry + * + * @details + * + * Function : SchProcStatisticsGrpTmrExp + * + * This function calculates and sends statistics of + * the stats-group for which timer expired. + * Once Statistics Indication is sent, timer for this + * group is restarted. + * + * @param[in] Statistics group control block + * @return uint8_t + * -# ROK + **/ +uint8_t SchProcStatisticsGrpTmrExp(SchStatsGrp *cb) +{ + if(schCalcAndSendGrpStats(cb) != ROK) + { + DU_LOG("\nERROR --> SCH : SchProcStatisticsGrpTmrExp: Fails to send group statistics"); + } + schStartTmr(&schCb[cb->schInst], (PTR)(cb), EVENT_STATISTICS_TMR, cb->periodicity); + return ROK; +} /** * @brief Timer Expiry handler. @@ -34,13 +192,34 @@ * about tmrEvnt=Bind timer. * * @param[in] PTR cb, Entry for which Timer expired - * @param[in] S16 tmrEvnt, the Timer Event + * @param[in] uint8_t tmrEvnt, the Timer Event * @return uint8_t * -# ROK **/ uint8_t schTmrExpiry(PTR cb, uint8_t tmrEvnt) { - /* TODO : Handling of any timer event expiry */ +#ifdef DEBUG_PRINT + DU_LOG("\nDEBUG --> SCH : Timer Expired. Event [%d]", tmrEvnt); +#endif + + switch (tmrEvnt) + { + case EVENT_STATISTICS_TMR: + { +#ifdef DEBUG_PRINT + DU_LOG("\nDEBUG --> SCH : Statistics Timer Expired for Subscription Id [%ld] GroupId [%d]", \ + ((SchStatsGrp*)cb)->subscriptionId, ((SchStatsGrp*)cb)->groupId); +#endif + SchProcStatisticsGrpTmrExp((SchStatsGrp*)cb); + break; + } + + default: + { + DU_LOG("\nERROR --> DU : duStartTmr: Invalid tmr Evnt [%d]", tmrEvnt); + break; + } + } return ROK; } @@ -65,8 +244,7 @@ short int schActvTmr(Ent ent,Inst inst) Inst schInst = (inst - SCH_INST_START); /* Check if any timer in the scheduler instance has expired */ - cmPrcTmr(&schCb[schInst].tmrTqCp, - schCb[schInst].tmrTq, (PFV) schTmrExpiry); + cmPrcTmr(&schCb[schInst].schTimersInfo.tmrTqCp, schCb[schInst].schTimersInfo.tmrTq, (PFV) schTmrExpiry); return ROK;