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 "rlc_env.h" /* RLC environment options */
43 #include "rlc_err.h" /* Error defines */
45 /* extern (.x) include files */
46 #include "lkw.x" /* LKW */
47 #include "ckw.x" /* CKW */
48 #include "kwu.x" /* KWU */
49 #include "rgu.x" /* RGU */
51 #include "du_app_rlc_inf.h"
52 #include "rlc_utils.h" /* RLC defines */
53 #include "rlc_dl_ul_inf.h"
60 * @brief RLC Timer Module
64 * @def RLC_TMR_CALCUATE_WAIT
66 * This macro calculates and assigns wait time based on the value of the
67 * timer and the timer resolution. Timer value of 0 signifies that the
68 * timer is not configured
70 * @param[out] _wait Time for which to arm the timer changed to proper
71 * value according to the resolution
72 * @param[in] _tmrVal Value of the timer
73 * @param[in] _timerRes Resolution of the timer
76 #define RLC_TMR_CALCUATE_WAIT(_wait, _tmrVal, _timerRes) \
78 (_wait) = ((_tmrVal) * SS_TICKS_SEC)/((_timerRes) * 1000); \
79 if((0 != (_tmrVal)) && (0 == (_wait))) \
85 /* private function declarations */
86 static Void rlcBndTmrExpiry(PTR cb);
89 * @brief Handler to start timer
91 * @param[in] gCb Pointer to the RLC instance control block
92 * @param[in] cb Control block depending on the type of the timer event.
93 * It can be uplink/downlink rbCb or rgu sap control block
94 * @param[in] tmrEvnt Timer event to be started
98 void rlcStartTmr(RlcCb *gCb, PTR cb, int16_t tmrEvnt)
100 /* kw005.201 added support for L2 Measurement */
102 RlcL2MeasEvtCb *measEvtCb = NULLP;
108 /* kw002.201 Adjusting the wait time as per timeRes configured by layer manager */
111 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
113 RlcUmUl* umUl = &(((RlcUlRbCb *)cb)->m.umUl);
114 /* kw005.201 Changed wait calculation ccpu00117634*/
115 RLC_TMR_CALCUATE_WAIT(arg.wait, umUl->reAsmblTmrInt, gCb->genCfg.timeRes);
117 arg.timers = &umUl->reAsmblTmr;
118 arg.max = RLC_MAX_UM_TMR;
121 case EVENT_RLC_AMUL_REASSEMBLE_TMR:
123 RlcAmUl* amUl = &(((RlcUlRbCb *)cb)->m.amUl);
124 /* kw005.201 Changed wait calculation ccpu00117634*/
125 RLC_TMR_CALCUATE_WAIT(arg.wait, amUl->reAsmblTmrInt, gCb->genCfg.timeRes);
127 arg.timers = &amUl->reAsmblTmr;
128 arg.max = RLC_MAX_AM_TMR;
131 case EVENT_RLC_AMUL_STA_PROH_TMR:
133 RlcAmUl* amUl = &(((RlcUlRbCb *)cb)->m.amUl);
134 /* kw005.201 Changed wait calculation ccpu00117634*/
135 RLC_TMR_CALCUATE_WAIT(arg.wait,
137 gCb->genCfg.timeRes);
139 arg.timers = &amUl->staProhTmr;
140 arg.max = RLC_MAX_AM_TMR;
143 case EVENT_RLC_AMDL_POLL_RETX_TMR:
145 RlcAmDl* amDl = &(((RlcDlRbCb *)cb)->m.amDl);
146 /* kw005.201 Changed wait calculation ccpu00117634*/
147 RLC_TMR_CALCUATE_WAIT(arg.wait,
148 amDl->pollRetxTmrInt,
149 gCb->genCfg.timeRes);
151 arg.timers = &amDl->pollRetxTmr;
152 arg.max = RLC_MAX_AM_TMR;
155 case EVENT_RLC_WAIT_BNDCFM:
157 RlcRguSapCb* rguSap = (RlcRguSapCb *)cb;
158 /* kw005.201 Changed wait calculation ccpu00117634*/
159 RLC_TMR_CALCUATE_WAIT(arg.wait, rguSap->bndTmrInt, gCb->genCfg.timeRes);
161 arg.timers = &rguSap->bndTmr;
162 arg.max = RLC_MAX_RGUSAP_TMR;
165 /* kw005.201 added support for L2 Measurement */
167 case EVENT_RLC_L2_TMR:
169 measEvtCb = (RlcL2MeasEvtCb *)cb;
170 /* kw005.201 Changed wait calculation ccpu00117634*/
171 RLC_TMR_CALCUATE_WAIT(arg.wait,
172 measEvtCb->l2TmrCfg.val,
173 gCb->genCfg.timeRes);
175 arg.timers = &measEvtCb->l2Tmr;
176 arg.max = RLC_L2_MAX_TIMERS;
180 case EVENT_RLC_THROUGHPUT_TMR:
182 RlcThpt *thptCb = (RlcThpt *)cb;
183 RLC_TMR_CALCUATE_WAIT(arg.wait, ODU_THROUGHPUT_PRINT_TIME_INTERVAL, gCb->genCfg.timeRes);
184 arg.timers = &thptCb->thptTmr;
185 arg.max = RLC_MAX_THPT_TMR;
188 case EVENT_RLC_UE_DELETE_TMR:
190 RlcUlUeCb *ulUeCb = (RlcUlUeCb*)cb;
191 RLC_TMR_CALCUATE_WAIT(arg.wait, RLC_UE_DELETE_WAIT_TIME, gCb->genCfg.timeRes);
192 arg.timers = &ulUeCb->ueDeleteInfo.ueDelTmr;
193 arg.max = RLC_MAX_UE_TMR;
198 DU_LOG("\nERROR --> RLC : rlcStartTmr: Invalid tmr Evnt [%d]", tmrEvnt);
204 arg.tqCp = &gCb->rlcTqCp;
217 * @brief Handler to stop a timer
219 * @param[in] gCb Pointer to the RLC instance control block
220 * @param[in] cb Control block depending on the type of the timer event.
221 * It can be uplink/downlink rbCb or rgu sap control block
222 * @param[in] tmrType Timer event to be started
226 void rlcStopTmr(RlcCb *gCb, PTR cb, uint8_t tmrType)
229 /* kw005.201 added support for L2 Measurement */
231 RlcL2MeasEvtCb *measEvtCb = NULLP;
238 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
240 arg.timers = &((RlcUlRbCb *)cb)->m.umUl.reAsmblTmr;
241 arg.max = RLC_MAX_UM_TMR;
244 case EVENT_RLC_AMUL_REASSEMBLE_TMR:
246 arg.timers = &((RlcUlRbCb *)cb)->m.amUl.reAsmblTmr;
247 arg.max = RLC_MAX_AM_TMR;
250 case EVENT_RLC_AMUL_STA_PROH_TMR:
252 arg.timers = &((RlcUlRbCb *)cb)->m.amUl.staProhTmr;
253 arg.max = RLC_MAX_AM_TMR;
256 case EVENT_RLC_AMDL_POLL_RETX_TMR:
258 arg.timers = &((RlcDlRbCb *)cb)->m.amDl.pollRetxTmr;
259 arg.max = RLC_MAX_AM_TMR;
262 case EVENT_RLC_WAIT_BNDCFM:
264 arg.timers = &((RlcRguSapCb *)cb)->bndTmr;
265 arg.max = RLC_MAX_RGUSAP_TMR;
268 /* kw005.201 added support for L2 Measurement */
270 case EVENT_RLC_L2_TMR:
272 measEvtCb = (RlcL2MeasEvtCb *)cb;
273 arg.timers = &measEvtCb->l2Tmr;
274 arg.max = RLC_L2_MAX_TIMERS;
278 case EVENT_RLC_THROUGHPUT_TMR:
280 arg.timers = &((RlcThpt *)cb)->thptTmr;
281 arg.max = RLC_MAX_THPT_TMR;
283 case EVENT_RLC_UE_DELETE_TMR:
285 arg.timers = &((RlcUlUeCb*)cb)->ueDeleteInfo.ueDelTmr;
286 arg.max = EVENT_RLC_UE_DELETE_TMR;
290 DU_LOG("\nERROR --> RLC : rlcStopTmr: Invalid tmr Evnt[%d]", tmrType);
295 arg.tqCp = &gCb->rlcTqCp;
308 * @brief Handler to invoke events on expiry of timer.
311 * This function is used to handle expiry of timer,it invokes relevant
314 * @param[in] cb Control block depending on the type of the timer event.
315 * It can be uplink/downlink rbCb or rgu sap control block
316 * @param[in] tmrEvnt Timer event to be started
320 Void rlcTmrExpiry(PTR cb,S16 tmrEvnt)
322 /* kw005.201 added support for L2 Measurement */
326 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
328 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
329 rlcUmmReAsmblTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
333 case EVENT_RLC_AMUL_REASSEMBLE_TMR:
335 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
336 rlcAmmReAsmblTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
339 case EVENT_RLC_AMUL_STA_PROH_TMR:
341 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
342 rlcAmmStaProTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
346 case EVENT_RLC_AMDL_POLL_RETX_TMR:
348 RlcDlRbCb *dlRbCb = (RlcDlRbCb *)cb;
349 RlcCb *gCb = RLC_GET_RLCCB(dlRbCb->inst);
351 rlcAmmPollRetxTmrExp(gCb, dlRbCb);
353 gCb->genSts.protTimeOut++;
356 case EVENT_RLC_WAIT_BNDCFM:
361 case EVENT_RLC_THROUGHPUT_TMR:
363 rlcThptTmrExpiry(cb);
366 case EVENT_RLC_UE_DELETE_TMR:
368 rlcUeDeleteTmrExpiry(cb);
381 * @brief Handler to check if the timer is running
383 * @param[in] gCb Pointer to the RLC instance control block
384 * @param[in] cb Control block depending on the type of the timer event.
385 * It can be uplink/downlink rbCb or rgu sap control block
386 * @param[in] tmrEvnt Timer event to be started
388 * @return Bool indicating whether the timer is running or not
392 bool rlcChkTmr(RlcCb *gCb, PTR cb, int16_t tmrEvnt)
396 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
398 return (((RlcUlRbCb *)cb)->m.umUl.reAsmblTmr.tmrEvnt ==
399 EVENT_RLC_UMUL_REASSEMBLE_TMR);
401 case EVENT_RLC_AMUL_REASSEMBLE_TMR:
403 return (((RlcUlRbCb *)cb)->m.amUl.reAsmblTmr.tmrEvnt ==
404 EVENT_RLC_AMUL_REASSEMBLE_TMR);
406 case EVENT_RLC_AMUL_STA_PROH_TMR:
408 return (((RlcUlRbCb *)cb)->m.amUl.staProhTmr.tmrEvnt ==
409 EVENT_RLC_AMUL_STA_PROH_TMR);
411 case EVENT_RLC_AMDL_POLL_RETX_TMR:
413 return (((RlcDlRbCb *)cb)->m.amDl.pollRetxTmr.tmrEvnt ==
414 EVENT_RLC_AMDL_POLL_RETX_TMR);
416 case EVENT_RLC_WAIT_BNDCFM:
418 return (((RlcRguSapCb *)cb)->bndTmr.tmrEvnt == EVENT_RLC_WAIT_BNDCFM);
420 case EVENT_RLC_THROUGHPUT_TMR:
422 return (((RlcThpt *)cb)->thptTmr.tmrEvnt == EVENT_RLC_THROUGHPUT_TMR);
424 case EVENT_RLC_UE_DELETE_TMR:
426 return (((RlcUlUeCb *)cb)->ueDeleteInfo.ueDelTmr.tmrEvnt == EVENT_RLC_UE_DELETE_TMR);
430 DU_LOG("\nERROR --> RLC : rlcChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
438 * @brief Handler to do processing on expiry of the bind timer
441 * This function processes the RLC bind timer expiry. If the number of
442 * retries is less than the maximum retry counter, bind request is sent
443 * again, else an alarm is raised to the layer manager.
445 * @param[in] cb Pointer to the Rgu sap
449 static Void rlcBndTmrExpiry(PTR cb)
451 RlcRguSapCb *rguSapCb;
453 rguSapCb = (RlcRguSapCb *) cb;
455 if (rguSapCb->state == RLC_SAP_BINDING)
457 if (rguSapCb->retryCnt < RLC_MAX_SAP_BND_RETRY)
459 /* start timer to wait for bind confirm */
460 rlcStartTmr(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
462 EVENT_RLC_WAIT_BNDCFM);
464 /* Send bind request */
465 rguSapCb->retryCnt++;
466 RlcLiRguBndReq (&rguSapCb->pst, rguSapCb->suId, rguSapCb->spId);
470 rguSapCb->retryCnt = 0;
471 rguSapCb->state = RLC_SAP_CFG;
473 /* Send alarm to the layer manager */
475 rlcLmmSendAlarm(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
476 LCM_CATEGORY_INTERFACE,
478 LCM_CAUSE_TMR_EXPIRED,
483 rlcLmmSendAlarm(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
484 LCM_CATEGORY_INTERFACE,
486 LCM_CAUSE_TMR_EXPIRED,
497 * @brief Handler to do processing on expiry of the throughput timer
500 * This function processes the RLC throughput timer expiry.
502 * @param[in] cb Pointer to the RLC throughput struct
506 void rlcThptTmrExpiry(PTR cb)
510 RlcThpt *rlcThptCb = (RlcThpt*)cb;
512 /* If cell is not up, throughput details cannot be printed */
513 if(gCellStatus != CELL_UP)
516 rlcStartTmr(RLC_GET_RLCCB(rlcThptCb->inst), (PTR)rlcThptCb, EVENT_RLC_THROUGHPUT_TMR);
520 /* If cell is up, print throughout for each UE attached to the cell */
521 DU_LOG("\n===================== DL Throughput ==============================");
522 DU_LOG("\nNumber of UEs : %d", rlcThptCb->numActvUe);
523 if(rlcThptCb->numActvUe)
525 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
527 if(rlcThptCb->thptPerUe[ueIdx].ueId)
529 /* Spec 28.552, section 5.1.1.3 :
530 * Throughput in kilobits/sec = (dataVol in kiloBits * 1000)/time in milligseconds
532 * Since our dataVol is in bytes, multiplying 0.008 to covert into kilobits i.e.
533 * Throughput[kbits/sec] = (dataVol * 0.008 * 1000)/time in ms
535 tpt = (double)(rlcThptCb->thptPerUe[ueIdx].dataVol * 8)/(double)ODU_THROUGHPUT_PRINT_TIME_INTERVAL;
537 DU_LOG("\nUE Id : %d DL Tpt : %.2Lf", rlcThptCb->thptPerUe[ueIdx].ueId, tpt);
538 rlcThptCb->thptPerUe[ueIdx].dataVol = 0;
542 DU_LOG("\n==================================================================");
545 rlcStartTmr(RLC_GET_RLCCB(rlcThptCb->inst), (PTR)rlcThptCb, EVENT_RLC_THROUGHPUT_TMR);
552 * @brief filling RLC UE delete configuration
555 * filling RLC UE delete configuration
557 * @params[in] RlcUlUeCb *ueCb, RlcCfgInfo *rlcUeCfg
563 void fillRlcUeDelInfo(RlcUlUeCb *ueCb, RlcCfgInfo *rlcUeCfg)
567 rlcUeCfg->ueId = ueCb->ueId;
568 rlcUeCfg->cellId = ueCb->cellId;
569 rlcUeCfg->numEnt = 0;
570 for(lcIdx=0; lcIdx<RLC_MAX_LCH_PER_UE && rlcUeCfg->numEnt < 1; lcIdx++)
572 if(ueCb->lCh[lcIdx].ulRbCb != NULLP)
574 rlcUeCfg->entCfg[rlcUeCfg->numEnt].rbId = 0;
575 rlcUeCfg->entCfg[rlcUeCfg->numEnt].rbType = 0;
576 rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CKW_CFG_DELETE_UE;
583 * @brief Handler to do processing on expiry of the UE delete timer
586 * This function processes the RLC UE delete timer expiry.
588 * @param[in] cb Pointer to the RlcUlUeCb
593 uint8_t rlcUeDeleteTmrExpiry(PTR cb)
595 RlcCb *gRlcCb = NULLP;
596 RlcCfgInfo *rlcUeCfg = NULLP;
597 RlcUlUeCb *ueCb = (RlcUlUeCb*)cb;
599 gRlcCb = RLC_GET_RLCCB(ueCb->ueDeleteInfo.pst.dstInst);
600 RLC_ALLOC(gRlcCb, rlcUeCfg, sizeof(RlcCfgInfo));
601 if(rlcUeCfg == NULLP)
603 DU_LOG("\nERROR --> RLC: rlcUeDeleteTmrExpiry(): Failed to allocate memory");
606 memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
607 fillRlcUeDelInfo(ueCb, rlcUeCfg);
608 if(RlcProcCfgReq(&ueCb->ueDeleteInfo.pst, rlcUeCfg) != ROK)
610 DU_LOG("\nERROR --> RLC: rlcUeDeleteTmrExpiry(): Failed to delete UE");
611 if(sendRlcUeDeleteRspToDu(rlcUeCfg->cellId, rlcUeCfg->ueId, INVALID_UEID) != ROK)
613 DU_LOG("ERROR --> RLC: rlcUeDeleteTmrExpiry(): Failed to send UE delete response ");
620 /********************************************************************30**
623 **********************************************************************/