1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 #include "common_def.h"
25 #include "du_app_rlc_inf.h"
26 #include "du_app_mac_inf.h"
28 #include "du_e2ap_mgr.h"
30 #include "du_e2ap_msg_hdl.h"
33 * @brief Handler to check if the timer is running
35 * @param[in] cb Control block depending on the type of the timer event.
36 * It can be uplink/downlink rbCb or rgu sap control block
37 * @param[in] tmrEvnt Timer event to be started
39 * @return Bool indicating whether the timer is running or not
44 bool duChkTmr(PTR cb, int16_t tmrEvnt)
48 case EVENT_E2_SETUP_TMR:
50 if(((CmTimer *)cb)->tmrEvnt == EVENT_E2_SETUP_TMR)
52 DU_LOG("\nERROR --> DU_APP : duChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
57 case EVENT_RIC_SERVICE_UPDATE_TMR:
59 if(((RicServiceUpdateTimer*)cb)->timer.tmrEvnt == EVENT_RIC_SERVICE_UPDATE_TMR)
61 DU_LOG("\nERROR --> DU_APP : duChkTmr: Timer already running for event [%d]", tmrEvnt);
66 case EVENT_E2_NODE_CONFIG_UPDATE_TMR:
68 if(((E2NodeConfigUpdateTimer *)cb)->timer.tmrEvnt == EVENT_E2_NODE_CONFIG_UPDATE_TMR)
70 DU_LOG("\nERROR --> DU_APP : duChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
75 case EVENT_RIC_SUBSCRIPTION_REPORTING_TMR:
77 if(((RicSubscription *)cb)->ricSubsReportTimer.tmrEvnt == EVENT_RIC_SUBSCRIPTION_REPORTING_TMR)
79 DU_LOG("\nERROR --> DU_APP : duChkTmr: Timer already running for event [%d]", tmrEvnt);
86 DU_LOG("\nERROR --> DU_APP : duChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
94 * @brief Handler to start timer
96 * @param[in] cb Control block depending on the type of the timer event.
97 * It can be uplink/downlink rbCb or rgu sap control block
98 * @param[in] tmrEvnt Timer event to be started
103 void duStartTmr(PTR cb, int16_t tmrEvnt, uint32_t timerValue)
110 case EVENT_E2_SETUP_TMR:
112 CmTimer *e2SetupTimer = NULLP;
113 e2SetupTimer = ((CmTimer *)cb);
114 TMR_CALCUATE_WAIT(arg.wait, timerValue, duCb.duTimersInfo.tmrRes);
116 arg.timers = e2SetupTimer;
117 arg.max = MAX_E2_SETUP_TMR;
120 case EVENT_RIC_SERVICE_UPDATE_TMR:
122 RicServiceUpdateTimer *ricServiceUpdateTimer = NULLP;
123 ricServiceUpdateTimer= ((RicServiceUpdateTimer*)cb);
124 TMR_CALCUATE_WAIT(arg.wait, timerValue, duCb.duTimersInfo.tmrRes);
126 arg.timers = &ricServiceUpdateTimer->timer;
127 arg.max = MAX_RIC_SERVICE_UPDATE_TMR;
130 case EVENT_E2_NODE_CONFIG_UPDATE_TMR:
132 E2NodeConfigUpdateTimer *cfgUpdateTimer;
133 cfgUpdateTimer = ((E2NodeConfigUpdateTimer*)cb);
134 TMR_CALCUATE_WAIT(arg.wait, timerValue, duCb.duTimersInfo.tmrRes);
136 arg.timers = &cfgUpdateTimer->timer;
137 arg.max = MAX_E2_NODE_CONFIG_UPDATE_TMR;
140 case EVENT_RIC_SUBSCRIPTION_REPORTING_TMR:
142 RicSubscription *ricSubscription = NULLP;
143 ricSubscription = ((RicSubscription*)cb);
144 TMR_CALCUATE_WAIT(arg.wait, timerValue, duCb.duTimersInfo.tmrRes);
146 arg.timers = &ricSubscription->ricSubsReportTimer;
147 arg.max = MAX_RIC_SUBSCRIPTION_REPORTING_TMR;
152 DU_LOG("\nERROR --> DU : duStartTmr: Invalid tmr Evnt [%d]", tmrEvnt);
159 arg.tqCp = &(duCb.duTimersInfo.tmrTqCp);
160 arg.tq = duCb.duTimersInfo.tmrTq;
171 * @brief Handler to invoke events on expiry of timer.
174 * This function is used to handle expiry of timer,it invokes relevant
177 * @param[in] cb Control block depending on the type of the timer event.
178 * It can be uplink/downlink rbCb or rgu sap control block
179 * @param[in] tmrEvnt Timer event to be started
184 void duTmrExpiry(PTR cb,int16_t tmrEvnt)
188 case EVENT_E2_SETUP_TMR:
190 BuildAndSendE2SetupReq();
193 case EVENT_RIC_SERVICE_UPDATE_TMR:
195 RicServiceUpdateTimer *ricServiceUpdateTimer;
197 ricServiceUpdateTimer= ((RicServiceUpdateTimer*)cb);
198 BuildAndSendRicServiceUpdate(ricServiceUpdateTimer->ricService);
201 case EVENT_E2_NODE_CONFIG_UPDATE_TMR:
203 E2NodeConfigUpdateTimer *cfgUpdateTimer;
205 cfgUpdateTimer = ((E2NodeConfigUpdateTimer*)cb);
206 BuildAndSendE2NodeConfigUpdate(&cfgUpdateTimer->configList);
209 case EVENT_RIC_SUBSCRIPTION_REPORTING_TMR:
211 RicSubscription *ricSubscription = NULLP;
213 ricSubscription = ((RicSubscription *)cb);
214 E2apHdlRicSubsReportTmrExp(ricSubscription);
219 DU_LOG("\nERROR --> DU : duStartTmr: Invalid tmr Evnt [%d]", tmrEvnt);
228 * @brief Handler to stop timer
230 * @param[in] cb Control block depending on the type of the timer event.
231 * @param[in] tmrEvnt Timer event to be stopped
236 void duStopTmr(PTR cb, uint8_t tmrType)
243 case EVENT_E2_SETUP_TMR:
245 CmTimer *e2SetupTimer = NULLP;
247 e2SetupTimer = ((CmTimer *)cb);
248 arg.timers = e2SetupTimer;
249 arg.max = MAX_E2_SETUP_TMR;
252 case EVENT_RIC_SERVICE_UPDATE_TMR:
254 RicServiceUpdateTimer *ricServiceUpdateTimer = NULLP;
256 ricServiceUpdateTimer= ((RicServiceUpdateTimer*)cb);
257 arg.timers = &ricServiceUpdateTimer->timer;
258 arg.max = MAX_RIC_SERVICE_UPDATE_TMR;
261 case EVENT_E2_NODE_CONFIG_UPDATE_TMR:
263 E2NodeConfigUpdateTimer *cfgUpdateTimer;
265 cfgUpdateTimer = ((E2NodeConfigUpdateTimer*)cb);
266 arg.timers = &cfgUpdateTimer->timer;
267 arg.max = MAX_E2_NODE_CONFIG_UPDATE_TMR;
270 case EVENT_RIC_SUBSCRIPTION_REPORTING_TMR:
272 RicSubscription *ricSubscription = NULLP;
274 ricSubscription = ((RicSubscription*)cb);
275 arg.timers = &ricSubscription->ricSubsReportTimer;
276 arg.max = MAX_RIC_SUBSCRIPTION_REPORTING_TMR;
281 DU_LOG("\nERROR --> RLC : rlcStopTmr: Invalid tmr Evnt[%d]", tmrType);
288 arg.tqCp = &(duCb.duTimersInfo.tmrTqCp);
289 arg.tq = duCb.duTimersInfo.tmrTq;
301 * @brief DU instance timer call back function registered with system services.
305 * Function : duActvTmr
307 * This function is invoked for every timer activation
308 * period expiry. Note that SS_MT_TMR flag needs to be enabled for this
309 * as isntId is needed.As part of SRegTmr call for du instance
310 * SS_MT_TMR flag needs to be enabled and duActvTmr needs to be given as
317 short int duActvTmr(Ent ent,Inst inst)
319 /* Check if any timer in the du instance has expired */
320 cmPrcTmr(&(duCb.duTimersInfo.tmrTqCp), duCb.duTimersInfo.tmrTq, (PFV) duTmrExpiry);
324 } /* end of duActvTmr */
326 /**********************************************************************
329 **********************************************************************/