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 /********************************************************************20**
21 Name: RLC - TMR module file
25 Desc: Source code for timer functions such as,
34 *********************************************************************21*/
36 /* header (.h) include files */
37 #include "common_def.h"
38 #include "lkw.h" /* LKW defines */
39 #include "ckw.h" /* CKW defines */
40 #include "kwu.h" /* KWU defines */
41 #include "rgu.h" /* RGU defines */
42 #include "kw_env.h" /* RLC environment options */
44 #include "kw.h" /* RLC defines */
45 #include "kw_err.h" /* Error defines */
50 /* extern (.x) include files */
51 #include "lkw.x" /* LKW */
52 #include "ckw.x" /* CKW */
53 #include "kwu.x" /* KWU */
54 #include "rgu.x" /* RGU */
63 * @brief RLC Timer Module
67 * @def RLC_TMR_CALCUATE_WAIT
69 * This macro calculates and assigns wait time based on the value of the
70 * timer and the timer resolution. Timer value of 0 signifies that the
71 * timer is not configured
73 * @param[out] _wait Time for which to arm the timer changed to proper
74 * value according to the resolution
75 * @param[in] _tmrVal Value of the timer
76 * @param[in] _timerRes Resolution of the timer
79 #define RLC_TMR_CALCUATE_WAIT(_wait, _tmrVal, _timerRes) \
81 (_wait) = ((_tmrVal) * SS_TICKS_SEC)/((_timerRes) * 1000); \
82 if((0 != (_tmrVal)) && (0 == (_wait))) \
88 /* private function declarations */
89 static Void rlcBndTmrExpiry(PTR cb);
92 * @brief Handler to start timer
94 * @param[in] gCb Pointer to the RLC instance control block
95 * @param[in] cb Control block depending on the type of the timer event.
96 * It can be uplink/downlink rbCb or rgu sap control block
97 * @param[in] tmrEvnt Timer event to be started
101 void rlcStartTmr(RlcCb *gCb, PTR cb, int16_t tmrEvnt)
103 /* kw005.201 added support for L2 Measurement */
105 RlcL2MeasEvtCb *measEvtCb = NULLP;
111 /* kw002.201 Adjusting the wait time as per timeRes configured by layer manager */
114 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
116 RlcUmUl* umUl = &(((RlcUlRbCb *)cb)->m.umUl);
117 /* kw005.201 Changed wait calculation ccpu00117634*/
118 RLC_TMR_CALCUATE_WAIT(arg.wait, umUl->reAsmblTmrInt, gCb->genCfg.timeRes);
120 arg.timers = &umUl->reAsmblTmr;
121 arg.max = RLC_MAX_UM_TMR;
124 case EVENT_RLC_AMUL_REORD_TMR:
126 RlcAmUl* amUl = &(((RlcUlRbCb *)cb)->m.amUl);
127 /* kw005.201 Changed wait calculation ccpu00117634*/
128 RLC_TMR_CALCUATE_WAIT(arg.wait, amUl->reOrdTmrInt, gCb->genCfg.timeRes);
130 arg.timers = &amUl->reOrdTmr;
131 arg.max = RLC_MAX_AM_TMR;
134 case EVENT_RLC_AMUL_STA_PROH_TMR:
136 RlcAmUl* amUl = &(((RlcUlRbCb *)cb)->m.amUl);
137 /* kw005.201 Changed wait calculation ccpu00117634*/
138 RLC_TMR_CALCUATE_WAIT(arg.wait,
140 gCb->genCfg.timeRes);
142 arg.timers = &amUl->staProhTmr;
143 arg.max = RLC_MAX_AM_TMR;
146 case EVENT_RLC_AMDL_POLL_RETX_TMR:
148 RlcAmDl* amDl = &(((RlcDlRbCb *)cb)->m.amDl);
149 /* kw005.201 Changed wait calculation ccpu00117634*/
150 RLC_TMR_CALCUATE_WAIT(arg.wait,
151 amDl->pollRetxTmrInt,
152 gCb->genCfg.timeRes);
154 arg.timers = &amDl->pollRetxTmr;
155 arg.max = RLC_MAX_AM_TMR;
158 case EVENT_RLC_WAIT_BNDCFM:
160 RlcRguSapCb* rguSap = (RlcRguSapCb *)cb;
161 /* kw005.201 Changed wait calculation ccpu00117634*/
162 RLC_TMR_CALCUATE_WAIT(arg.wait, rguSap->bndTmrInt, gCb->genCfg.timeRes);
164 arg.timers = &rguSap->bndTmr;
165 arg.max = RLC_MAX_RGUSAP_TMR;
168 /* kw005.201 added support for L2 Measurement */
170 case EVENT_RLC_L2_TMR:
172 measEvtCb = (RlcL2MeasEvtCb *)cb;
173 /* kw005.201 Changed wait calculation ccpu00117634*/
174 RLC_TMR_CALCUATE_WAIT(arg.wait,
175 measEvtCb->l2TmrCfg.val,
176 gCb->genCfg.timeRes);
178 arg.timers = &measEvtCb->l2Tmr;
179 arg.max = RLC_L2_MAX_TIMERS;
185 DU_LOG("\nERROR --> RLC : rlcStartTmr: Invalid tmr Evnt [%d]", tmrEvnt);
191 arg.tqCp = &gCb->rlcTqCp;
204 * @brief Handler to stop a timer
206 * @param[in] gCb Pointer to the RLC instance control block
207 * @param[in] cb Control block depending on the type of the timer event.
208 * It can be uplink/downlink rbCb or rgu sap control block
209 * @param[in] tmrType Timer event to be started
213 void rlcStopTmr(RlcCb *gCb, PTR cb, uint8_t tmrType)
216 /* kw005.201 added support for L2 Measurement */
218 RlcL2MeasEvtCb *measEvtCb = NULLP;
225 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
227 arg.timers = &((RlcUlRbCb *)cb)->m.umUl.reAsmblTmr;
228 arg.max = RLC_MAX_UM_TMR;
231 case EVENT_RLC_AMUL_REORD_TMR:
233 arg.timers = &((RlcUlRbCb *)cb)->m.amUl.reOrdTmr;
234 arg.max = RLC_MAX_AM_TMR;
237 case EVENT_RLC_AMUL_STA_PROH_TMR:
239 arg.timers = &((RlcUlRbCb *)cb)->m.amUl.staProhTmr;
240 arg.max = RLC_MAX_AM_TMR;
243 case EVENT_RLC_AMDL_POLL_RETX_TMR:
245 arg.timers = &((RlcDlRbCb *)cb)->m.amDl.pollRetxTmr;
246 arg.max = RLC_MAX_AM_TMR;
249 case EVENT_RLC_WAIT_BNDCFM:
251 arg.timers = &((RlcRguSapCb *)cb)->bndTmr;
252 arg.max = RLC_MAX_RGUSAP_TMR;
255 /* kw005.201 added support for L2 Measurement */
257 case EVENT_RLC_L2_TMR:
259 measEvtCb = (RlcL2MeasEvtCb *)cb;
260 arg.timers = &measEvtCb->l2Tmr;
261 arg.max = RLC_L2_MAX_TIMERS;
267 DU_LOG("\nERROR --> RLC : rlcStopTmr: Invalid tmr Evnt[%d]", tmrType);
272 arg.tqCp = &gCb->rlcTqCp;
285 * @brief Handler to invoke events on expiry of timer.
288 * This function is used to handle expiry of timer,it invokes relevant
291 * @param[in] cb Control block depending on the type of the timer event.
292 * It can be uplink/downlink rbCb or rgu sap control block
293 * @param[in] tmrEvnt Timer event to be started
297 Void rlcTmrExpiry(PTR cb,S16 tmrEvnt)
299 /* kw005.201 added support for L2 Measurement */
303 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
305 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
306 rlcUmmReAsmblTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
310 case EVENT_RLC_AMUL_REORD_TMR:
312 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
313 rlcAmmReOrdTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
316 case EVENT_RLC_AMUL_STA_PROH_TMR:
318 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
319 rlcAmmStaProTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
323 case EVENT_RLC_AMDL_POLL_RETX_TMR:
325 RlcDlRbCb *dlRbCb = (RlcDlRbCb *)cb;
326 RlcCb *gCb = RLC_GET_RLCCB(dlRbCb->inst);
328 rlcAmmPollRetxTmrExp(gCb, dlRbCb);
330 gCb->genSts.protTimeOut++;
333 case EVENT_RLC_WAIT_BNDCFM:
338 /* kw005.201 L2 Measurement support */
349 * @brief Handler to check if the timer is running
351 * @param[in] gCb Pointer to the RLC instance control block
352 * @param[in] cb Control block depending on the type of the timer event.
353 * It can be uplink/downlink rbCb or rgu sap control block
354 * @param[in] tmrEvnt Timer event to be started
356 * @return Bool indicating whether the timer is running or not
360 bool rlcChkTmr(RlcCb *gCb, PTR cb, int16_t tmrEvnt)
364 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
366 return (((RlcUlRbCb *)cb)->m.umUl.reAsmblTmr.tmrEvnt ==
367 EVENT_RLC_UMUL_REASSEMBLE_TMR);
369 case EVENT_RLC_AMUL_REORD_TMR:
371 return (((RlcUlRbCb *)cb)->m.amUl.reOrdTmr.tmrEvnt ==
372 EVENT_RLC_AMUL_REORD_TMR);
374 case EVENT_RLC_AMUL_STA_PROH_TMR:
376 return (((RlcUlRbCb *)cb)->m.amUl.staProhTmr.tmrEvnt ==
377 EVENT_RLC_AMUL_STA_PROH_TMR);
379 case EVENT_RLC_AMDL_POLL_RETX_TMR:
381 return (((RlcDlRbCb *)cb)->m.amDl.pollRetxTmr.tmrEvnt ==
382 EVENT_RLC_AMDL_POLL_RETX_TMR);
384 case EVENT_RLC_WAIT_BNDCFM:
386 return (((RlcRguSapCb *)cb)->bndTmr.tmrEvnt == EVENT_RLC_WAIT_BNDCFM);
390 DU_LOG("\nERROR --> RLC : rlcChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
398 * @brief Handler to do processing on expiry of the bind timer
401 * This function processes the RLC bind timer expiry. If the number of
402 * retries is less than the maximum retry counter, bind request is sent
403 * again, else an alarm is raised to the layer manager.
405 * @param[in] cb Pointer to the Rgu sap
409 static Void rlcBndTmrExpiry(PTR cb)
411 RlcRguSapCb *rguSapCb;
413 rguSapCb = (RlcRguSapCb *) cb;
415 if (rguSapCb->state == RLC_SAP_BINDING)
417 if (rguSapCb->retryCnt < RLC_MAX_SAP_BND_RETRY)
419 /* start timer to wait for bind confirm */
420 rlcStartTmr(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
422 EVENT_RLC_WAIT_BNDCFM);
424 /* Send bind request */
425 rguSapCb->retryCnt++;
426 RlcLiRguBndReq (&rguSapCb->pst, rguSapCb->suId, rguSapCb->spId);
430 rguSapCb->retryCnt = 0;
431 rguSapCb->state = RLC_SAP_CFG;
433 /* Send alarm to the layer manager */
435 rlcLmmSendAlarm(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
436 LCM_CATEGORY_INTERFACE,
438 LCM_CAUSE_TMR_EXPIRED,
443 rlcLmmSendAlarm(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
444 LCM_CATEGORY_INTERFACE,
446 LCM_CAUSE_TMR_EXPIRED,
458 /********************************************************************30**
461 **********************************************************************/