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 PRIVATE 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 RLC_EVT_UMUL_REORD_TMR:
116 RlcUmUl* umUl = &(((RlcUlRbCb *)cb)->m.umUl);
117 /* kw005.201 Changed wait calculation ccpu00117634*/
118 RLC_TMR_CALCUATE_WAIT(arg.wait, umUl->reOrdTmrInt, gCb->genCfg.timeRes);
120 arg.timers = &umUl->reOrdTmr;
121 arg.max = RLC_MAX_UM_TMR;
124 case RLC_EVT_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 RLC_EVT_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 RLC_EVT_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 RLC_EVT_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 */
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("\nRLC : 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 RLC_EVT_UMUL_REORD_TMR:
227 arg.timers = &((RlcUlRbCb *)cb)->m.umUl.reOrdTmr;
228 arg.max = RLC_MAX_UM_TMR;
231 case RLC_EVT_AMUL_REORD_TMR:
233 arg.timers = &((RlcUlRbCb *)cb)->m.amUl.reOrdTmr;
234 arg.max = RLC_MAX_AM_TMR;
237 case RLC_EVT_AMUL_STA_PROH_TMR:
239 arg.timers = &((RlcUlRbCb *)cb)->m.amUl.staProhTmr;
240 arg.max = RLC_MAX_AM_TMR;
243 case RLC_EVT_AMDL_POLL_RETX_TMR:
245 arg.timers = &((RlcDlRbCb *)cb)->m.amDl.pollRetxTmr;
246 arg.max = RLC_MAX_AM_TMR;
249 case RLC_EVT_WAIT_BNDCFM:
251 arg.timers = &((RlcRguSapCb *)cb)->bndTmr;
252 arg.max = RLC_MAX_RGUSAP_TMR;
255 /* kw005.201 added support for L2 Measurement */
259 measEvtCb = (RlcL2MeasEvtCb *)cb;
260 arg.timers = &measEvtCb->l2Tmr;
261 arg.max = RLC_L2_MAX_TIMERS;
267 DU_LOG("\nRLC : 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
304 Void rlcTmrExpiry (cb, tmrEvnt)
309 /* kw005.201 added support for L2 Measurement */
314 case RLC_EVT_UMUL_REORD_TMR:
316 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
317 rlcUmmReOrdTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
321 case RLC_EVT_AMUL_REORD_TMR:
323 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
324 rlcAmmReOrdTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
327 case RLC_EVT_AMUL_STA_PROH_TMR:
329 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
330 rlcAmmStaProTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
334 case RLC_EVT_AMDL_POLL_RETX_TMR:
336 RlcDlRbCb *dlRbCb = (RlcDlRbCb *)cb;
337 RlcCb *gCb = RLC_GET_RLCCB(dlRbCb->inst);
339 rlcAmmPollRetxTmrExp(gCb, dlRbCb);
341 gCb->genSts.protTimeOut++;
344 case RLC_EVT_WAIT_BNDCFM:
349 /* kw005.201 L2 Measurement support */
360 * @brief Handler to check if the timer is running
362 * @param[in] gCb Pointer to the RLC instance control block
363 * @param[in] cb Control block depending on the type of the timer event.
364 * It can be uplink/downlink rbCb or rgu sap control block
365 * @param[in] tmrEvnt Timer event to be started
367 * @return Bool indicating whether the timer is running or not
371 bool rlcChkTmr(RlcCb *gCb, PTR cb, int16_t tmrEvnt)
375 case RLC_EVT_UMUL_REORD_TMR:
377 return (((RlcUlRbCb *)cb)->m.umUl.reOrdTmr.tmrEvnt ==
378 RLC_EVT_UMUL_REORD_TMR);
380 case RLC_EVT_AMUL_REORD_TMR:
382 return (((RlcUlRbCb *)cb)->m.amUl.reOrdTmr.tmrEvnt ==
383 RLC_EVT_AMUL_REORD_TMR);
385 case RLC_EVT_AMUL_STA_PROH_TMR:
387 return (((RlcUlRbCb *)cb)->m.amUl.staProhTmr.tmrEvnt ==
388 RLC_EVT_AMUL_STA_PROH_TMR);
390 case RLC_EVT_AMDL_POLL_RETX_TMR:
392 return (((RlcDlRbCb *)cb)->m.amDl.pollRetxTmr.tmrEvnt ==
393 RLC_EVT_AMDL_POLL_RETX_TMR);
395 case RLC_EVT_WAIT_BNDCFM:
397 return (((RlcRguSapCb *)cb)->bndTmr.tmrEvnt == RLC_EVT_WAIT_BNDCFM);
401 DU_LOG("\nRLC : rlcChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
409 * @brief Handler to do processing on expiry of the bind timer
412 * This function processes the RLC bind timer expiry. If the number of
413 * retries is less than the maximum retry counter, bind request is sent
414 * again, else an alarm is raised to the layer manager.
416 * @param[in] cb Pointer to the Rgu sap
421 PRIVATE Void rlcBndTmrExpiry
426 PRIVATE Void rlcBndTmrExpiry(cb)
430 RlcRguSapCb *rguSapCb;
432 TRC2(rlcBndTmrExpiry)
434 rguSapCb = (RlcRguSapCb *) cb;
436 if (rguSapCb->state == RLC_SAP_BINDING)
438 if (rguSapCb->retryCnt < RLC_MAX_SAP_BND_RETRY)
440 /* start timer to wait for bind confirm */
441 rlcStartTmr(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
443 RLC_EVT_WAIT_BNDCFM);
445 /* Send bind request */
446 rguSapCb->retryCnt++;
447 RlcLiRguBndReq (&rguSapCb->pst, rguSapCb->suId, rguSapCb->spId);
451 rguSapCb->retryCnt = 0;
452 rguSapCb->state = RLC_SAP_CFG;
454 /* Send alarm to the layer manager */
456 rlcLmmSendAlarm(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
457 LCM_CATEGORY_INTERFACE,
459 LCM_CAUSE_TMR_EXPIRED,
464 rlcLmmSendAlarm(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
465 LCM_CATEGORY_INTERFACE,
467 LCM_CAUSE_TMR_EXPIRED,
479 /********************************************************************30**
482 **********************************************************************/