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);
90 * @brief Handler to start timer
92 * @param[in] gCb Pointer to the RLC instance control block
93 * @param[in] cb Control block depending on the type of the timer event.
94 * It can be uplink/downlink rbCb or rgu sap control block
95 * @param[in] tmrEvnt Timer event to be started
99 void rlcStartTmr(RlcCb *gCb, PTR cb, int16_t tmrEvnt)
101 /* kw005.201 added support for L2 Measurement */
103 RlcL2MeasEvtCb *measEvtCb = NULLP;
109 /* kw002.201 Adjusting the wait time as per timeRes configured by layer manager */
112 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
114 RlcUmUl* umUl = &(((RlcUlRbCb *)cb)->m.umUl);
115 /* kw005.201 Changed wait calculation ccpu00117634*/
116 RLC_TMR_CALCUATE_WAIT(arg.wait, umUl->reAsmblTmrInt, gCb->genCfg.timeRes);
118 arg.timers = &umUl->reAsmblTmr;
119 arg.max = RLC_MAX_UM_TMR;
122 case EVENT_RLC_AMUL_REASSEMBLE_TMR:
124 RlcAmUl* amUl = &(((RlcUlRbCb *)cb)->m.amUl);
125 /* kw005.201 Changed wait calculation ccpu00117634*/
126 RLC_TMR_CALCUATE_WAIT(arg.wait, amUl->reAsmblTmrInt, gCb->genCfg.timeRes);
128 arg.timers = &amUl->reAsmblTmr;
129 arg.max = RLC_MAX_AM_TMR;
132 case EVENT_RLC_AMUL_STA_PROH_TMR:
134 RlcAmUl* amUl = &(((RlcUlRbCb *)cb)->m.amUl);
135 /* kw005.201 Changed wait calculation ccpu00117634*/
136 RLC_TMR_CALCUATE_WAIT(arg.wait,
138 gCb->genCfg.timeRes);
140 arg.timers = &amUl->staProhTmr;
141 arg.max = RLC_MAX_AM_TMR;
144 case EVENT_RLC_AMDL_POLL_RETX_TMR:
146 RlcAmDl* amDl = &(((RlcDlRbCb *)cb)->m.amDl);
147 /* kw005.201 Changed wait calculation ccpu00117634*/
148 RLC_TMR_CALCUATE_WAIT(arg.wait,
149 amDl->pollRetxTmrInt,
150 gCb->genCfg.timeRes);
152 arg.timers = &amDl->pollRetxTmr;
153 arg.max = RLC_MAX_AM_TMR;
156 case EVENT_RLC_WAIT_BNDCFM:
158 RlcRguSapCb* rguSap = (RlcRguSapCb *)cb;
159 /* kw005.201 Changed wait calculation ccpu00117634*/
160 RLC_TMR_CALCUATE_WAIT(arg.wait, rguSap->bndTmrInt, gCb->genCfg.timeRes);
162 arg.timers = &rguSap->bndTmr;
163 arg.max = RLC_MAX_RGUSAP_TMR;
166 /* kw005.201 added support for L2 Measurement */
168 case EVENT_RLC_L2_TMR:
170 measEvtCb = (RlcL2MeasEvtCb *)cb;
171 /* kw005.201 Changed wait calculation ccpu00117634*/
172 RLC_TMR_CALCUATE_WAIT(arg.wait,
173 measEvtCb->l2TmrCfg.val,
174 gCb->genCfg.timeRes);
176 arg.timers = &measEvtCb->l2Tmr;
177 arg.max = RLC_L2_MAX_TIMERS;
181 case EVENT_RLC_UE_THROUGHPUT_TMR:
183 RlcThpt *thptCb = (RlcThpt *)cb;
184 RLC_TMR_CALCUATE_WAIT(arg.wait, ODU_UE_THROUGHPUT_PRINT_TIME_INTERVAL, gCb->genCfg.timeRes);
185 arg.timers = &thptCb->ueTputInfo.ueThptTmr;
186 arg.max = RLC_MAX_THPT_TMR;
189 case EVENT_RLC_UE_DELETE_TMR:
191 RlcUlUeCb *ulUeCb = (RlcUlUeCb*)cb;
192 RLC_TMR_CALCUATE_WAIT(arg.wait, RLC_UE_DELETE_WAIT_TIME, gCb->genCfg.timeRes);
193 arg.timers = &ulUeCb->ueDeleteInfo.ueDelTmr;
194 arg.max = RLC_MAX_UE_TMR;
197 case EVENT_RLC_SNSSAI_THROUGHPUT_TMR:
199 RlcThpt *thptCb = (RlcThpt *)cb;
200 RLC_TMR_CALCUATE_WAIT(arg.wait, ODU_SNSSAI_THROUGHPUT_PRINT_TIME_INTERVAL, gCb->genCfg.timeRes);
201 arg.timers = &thptCb->snssaiTputInfo.snssaiThptTmr;
202 arg.max = RLC_MAX_THPT_TMR;
207 DU_LOG("\nERROR --> RLC : rlcStartTmr: Invalid tmr Evnt [%d]", tmrEvnt);
213 arg.tqCp = &gCb->rlcTqCp;
226 * @brief Handler to stop a timer
228 * @param[in] gCb Pointer to the RLC instance control block
229 * @param[in] cb Control block depending on the type of the timer event.
230 * It can be uplink/downlink rbCb or rgu sap control block
231 * @param[in] tmrType Timer event to be started
235 void rlcStopTmr(RlcCb *gCb, PTR cb, uint8_t tmrType)
238 /* kw005.201 added support for L2 Measurement */
240 RlcL2MeasEvtCb *measEvtCb = NULLP;
247 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
249 arg.timers = &((RlcUlRbCb *)cb)->m.umUl.reAsmblTmr;
250 arg.max = RLC_MAX_UM_TMR;
253 case EVENT_RLC_AMUL_REASSEMBLE_TMR:
255 arg.timers = &((RlcUlRbCb *)cb)->m.amUl.reAsmblTmr;
256 arg.max = RLC_MAX_AM_TMR;
259 case EVENT_RLC_AMUL_STA_PROH_TMR:
261 arg.timers = &((RlcUlRbCb *)cb)->m.amUl.staProhTmr;
262 arg.max = RLC_MAX_AM_TMR;
265 case EVENT_RLC_AMDL_POLL_RETX_TMR:
267 arg.timers = &((RlcDlRbCb *)cb)->m.amDl.pollRetxTmr;
268 arg.max = RLC_MAX_AM_TMR;
271 case EVENT_RLC_WAIT_BNDCFM:
273 arg.timers = &((RlcRguSapCb *)cb)->bndTmr;
274 arg.max = RLC_MAX_RGUSAP_TMR;
277 /* kw005.201 added support for L2 Measurement */
279 case EVENT_RLC_L2_TMR:
281 measEvtCb = (RlcL2MeasEvtCb *)cb;
282 arg.timers = &measEvtCb->l2Tmr;
283 arg.max = RLC_L2_MAX_TIMERS;
287 case EVENT_RLC_UE_THROUGHPUT_TMR:
289 arg.timers = &((RlcThpt *)cb)->ueTputInfo.ueThptTmr;
290 arg.max = RLC_MAX_THPT_TMR;
293 case EVENT_RLC_UE_DELETE_TMR:
295 arg.timers = &((RlcUlUeCb*)cb)->ueDeleteInfo.ueDelTmr;
296 arg.max = EVENT_RLC_UE_DELETE_TMR;
299 case EVENT_RLC_SNSSAI_THROUGHPUT_TMR:
301 arg.timers = &((RlcThpt *)cb)->snssaiTputInfo.snssaiThptTmr;
302 arg.max = RLC_MAX_THPT_TMR;
307 DU_LOG("\nERROR --> RLC : rlcStopTmr: Invalid tmr Evnt[%d]", tmrType);
313 arg.tqCp = &gCb->rlcTqCp;
326 * @brief Handler to invoke events on expiry of timer.
329 * This function is used to handle expiry of timer,it invokes relevant
332 * @param[in] cb Control block depending on the type of the timer event.
333 * It can be uplink/downlink rbCb or rgu sap control block
334 * @param[in] tmrEvnt Timer event to be started
338 Void rlcTmrExpiry(PTR cb,S16 tmrEvnt)
340 /* kw005.201 added support for L2 Measurement */
344 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
346 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
347 rlcUmmReAsmblTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
351 case EVENT_RLC_AMUL_REASSEMBLE_TMR:
353 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
354 rlcAmmReAsmblTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
357 case EVENT_RLC_AMUL_STA_PROH_TMR:
359 RlcUlRbCb *ulRbCb = (RlcUlRbCb *)cb;
360 rlcAmmStaProTmrExp(RLC_GET_RLCCB(ulRbCb->inst), ulRbCb);
364 case EVENT_RLC_AMDL_POLL_RETX_TMR:
366 RlcDlRbCb *dlRbCb = (RlcDlRbCb *)cb;
367 RlcCb *gCb = RLC_GET_RLCCB(dlRbCb->inst);
369 rlcAmmPollRetxTmrExp(gCb, dlRbCb);
371 gCb->genSts.protTimeOut++;
374 case EVENT_RLC_WAIT_BNDCFM:
379 case EVENT_RLC_UE_THROUGHPUT_TMR:
381 rlcUeThptTmrExpiry(cb);
384 case EVENT_RLC_UE_DELETE_TMR:
386 rlcUeDeleteTmrExpiry(cb);
389 case EVENT_RLC_SNSSAI_THROUGHPUT_TMR:
391 rlcSnssaiThptTmrExpiry(cb);
404 * @brief Handler to check if the timer is running
406 * @param[in] gCb Pointer to the RLC instance control block
407 * @param[in] cb Control block depending on the type of the timer event.
408 * It can be uplink/downlink rbCb or rgu sap control block
409 * @param[in] tmrEvnt Timer event to be started
411 * @return Bool indicating whether the timer is running or not
415 bool rlcChkTmr(RlcCb *gCb, PTR cb, int16_t tmrEvnt)
419 case EVENT_RLC_UMUL_REASSEMBLE_TMR:
421 return (((RlcUlRbCb *)cb)->m.umUl.reAsmblTmr.tmrEvnt ==
422 EVENT_RLC_UMUL_REASSEMBLE_TMR);
424 case EVENT_RLC_AMUL_REASSEMBLE_TMR:
426 return (((RlcUlRbCb *)cb)->m.amUl.reAsmblTmr.tmrEvnt ==
427 EVENT_RLC_AMUL_REASSEMBLE_TMR);
429 case EVENT_RLC_AMUL_STA_PROH_TMR:
431 return (((RlcUlRbCb *)cb)->m.amUl.staProhTmr.tmrEvnt ==
432 EVENT_RLC_AMUL_STA_PROH_TMR);
434 case EVENT_RLC_AMDL_POLL_RETX_TMR:
436 return (((RlcDlRbCb *)cb)->m.amDl.pollRetxTmr.tmrEvnt ==
437 EVENT_RLC_AMDL_POLL_RETX_TMR);
439 case EVENT_RLC_WAIT_BNDCFM:
441 return (((RlcRguSapCb *)cb)->bndTmr.tmrEvnt == EVENT_RLC_WAIT_BNDCFM);
443 case EVENT_RLC_UE_THROUGHPUT_TMR:
445 return (((RlcThpt *)cb)->ueTputInfo.ueThptTmr.tmrEvnt == EVENT_RLC_UE_THROUGHPUT_TMR);
447 case EVENT_RLC_UE_DELETE_TMR:
449 return (((RlcUlUeCb *)cb)->ueDeleteInfo.ueDelTmr.tmrEvnt == EVENT_RLC_UE_DELETE_TMR);
451 case EVENT_RLC_SNSSAI_THROUGHPUT_TMR:
453 return (((RlcThpt *)cb)->snssaiTputInfo.snssaiThptTmr.tmrEvnt == EVENT_RLC_SNSSAI_THROUGHPUT_TMR);
457 DU_LOG("\nERROR --> RLC : rlcChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
465 * @brief Handler to do processing on expiry of the bind timer
468 * This function processes the RLC bind timer expiry. If the number of
469 * retries is less than the maximum retry counter, bind request is sent
470 * again, else an alarm is raised to the layer manager.
472 * @param[in] cb Pointer to the Rgu sap
476 static Void rlcBndTmrExpiry(PTR cb)
478 RlcRguSapCb *rguSapCb;
480 rguSapCb = (RlcRguSapCb *) cb;
482 if (rguSapCb->state == RLC_SAP_BINDING)
484 if (rguSapCb->retryCnt < RLC_MAX_SAP_BND_RETRY)
486 /* start timer to wait for bind confirm */
487 rlcStartTmr(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
489 EVENT_RLC_WAIT_BNDCFM);
491 /* Send bind request */
492 rguSapCb->retryCnt++;
493 RlcLiRguBndReq (&rguSapCb->pst, rguSapCb->suId, rguSapCb->spId);
497 rguSapCb->retryCnt = 0;
498 rguSapCb->state = RLC_SAP_CFG;
500 /* Send alarm to the layer manager */
502 rlcLmmSendAlarm(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
503 LCM_CATEGORY_INTERFACE,
505 LCM_CAUSE_TMR_EXPIRED,
510 rlcLmmSendAlarm(RLC_GET_RLCCB(rguSapCb->pst.srcInst),
511 LCM_CATEGORY_INTERFACE,
513 LCM_CAUSE_TMR_EXPIRED,
524 * @brief Handler to do processing on expiry of UE throughput timer
527 * This function processes the RLC UE throughput timer expiry.
529 * @param[in] cb Pointer to the RLC throughput struct
533 void rlcUeThptTmrExpiry(PTR cb)
537 RlcThpt *rlcThptCb = (RlcThpt*)cb;
539 /* If cell is not up, throughput details cannot be printed */
540 if(gCellStatus != CELL_UP)
543 rlcStartTmr(RLC_GET_RLCCB(rlcThptCb->inst), (PTR)(rlcThptCb), EVENT_RLC_UE_THROUGHPUT_TMR);
547 /* If cell is up, print throughout for each UE attached to the cell */
548 DU_LOG("\n===================== DL Throughput Per UE==============================");
549 DU_LOG("\nNumber of UEs : %d", rlcThptCb->ueTputInfo.numActvUe);
550 if(rlcThptCb->ueTputInfo.numActvUe)
552 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
554 if(rlcThptCb->ueTputInfo.thptPerUe[ueIdx].ueId)
556 /* Spec 28.552, section 5.1.1.3 :
557 * Throughput in kilobits/sec = (dataVol in kiloBits * 1000)/time in milligseconds
559 * Since our dataVol is in bytes, multiplying 0.008 to covert into kilobits i.e.
560 * Throughput[kbits/sec] = (dataVol * 0.008 * 1000)/time in ms
562 tpt = (double)(rlcThptCb->ueTputInfo.thptPerUe[ueIdx].dataVol * 8)/(double)ODU_UE_THROUGHPUT_PRINT_TIME_INTERVAL;
564 DU_LOG("\nUE Id : %d DL Tpt : %.2Lf", rlcThptCb->ueTputInfo.thptPerUe[ueIdx].ueId, tpt);
565 rlcThptCb->ueTputInfo.thptPerUe[ueIdx].dataVol = 0;
569 DU_LOG("\n==================================================================");
572 rlcStartTmr(RLC_GET_RLCCB(rlcThptCb->inst), (PTR)rlcThptCb, EVENT_RLC_UE_THROUGHPUT_TMR);
578 * @brief Handler to do processing on expiry of the SNSSAI throughput timer
581 * This function processes the RLC SNSSAI throughput timer expiry.
583 * @param[in] cb Pointer to the RLC throughput struct
587 void rlcSnssaiThptTmrExpiry(PTR cb)
589 RlcThpt *rlcThptCb = (RlcThpt*)cb;
591 static uint8_t snssaiCntDl = 0, snssaiCntUl = 0;
592 /*Bit map to keep record of reception of DL and UL Snssai Tput expiry*/
593 static uint8_t snssaiTputBitmap = DIR_NONE;
595 /* If cell is not up, throughput details cannot be printed */
596 if(gCellStatus != CELL_UP)
599 rlcStartTmr(RLC_GET_RLCCB(rlcThptCb->inst), (PTR)(rlcThptCb), EVENT_RLC_SNSSAI_THROUGHPUT_TMR);
603 if(rlcThptCb->snssaiTputInfo.dlTputPerSnssaiList != NULLP)
605 snssaiCntDl = rlcCalculateTputPerSnssai(rlcThptCb->snssaiTputInfo.dlTputPerSnssaiList, DIR_DL);
606 snssaiTputBitmap |= DIR_DL;
607 arrTputPerSnssai[DIR_DL] = rlcThptCb->snssaiTputInfo.dlTputPerSnssaiList;
609 if(rlcThptCb->snssaiTputInfo.ulTputPerSnssaiList != NULLP)
611 snssaiCntUl = rlcCalculateTputPerSnssai(rlcThptCb->snssaiTputInfo.ulTputPerSnssaiList, DIR_UL);
612 snssaiTputBitmap |= DIR_UL;
613 arrTputPerSnssai[DIR_UL] = rlcThptCb->snssaiTputInfo.ulTputPerSnssaiList;
615 if(snssaiTputBitmap == DIR_BOTH)
618 BuildSliceReportToDu(MAX(snssaiCntUl, snssaiCntDl));
619 snssaiTputBitmap = DIR_NONE;
622 rlcStartTmr(RLC_GET_RLCCB(rlcThptCb->inst), (PTR)rlcThptCb, EVENT_RLC_SNSSAI_THROUGHPUT_TMR);
627 * @brief filling RLC UE delete configuration
630 * filling RLC UE delete configuration
632 * @params[in] RlcUlUeCb *ueCb, RlcCfgInfo *rlcUeCfg
638 void fillRlcUeDelInfo(RlcUlUeCb *ueCb, RlcCfgInfo *rlcUeCfg)
642 rlcUeCfg->ueId = ueCb->ueId;
643 rlcUeCfg->cellId = ueCb->cellId;
644 rlcUeCfg->numEnt = 0;
645 for(lcIdx=0; lcIdx<RLC_MAX_LCH_PER_UE && rlcUeCfg->numEnt < 1; lcIdx++)
647 if(ueCb->lCh[lcIdx].ulRbCb != NULLP)
649 rlcUeCfg->entCfg[rlcUeCfg->numEnt].rbId = 0;
650 rlcUeCfg->entCfg[rlcUeCfg->numEnt].rbType = 0;
651 rlcUeCfg->entCfg[rlcUeCfg->numEnt].cfgType = CKW_CFG_DELETE_UE;
658 * @brief Handler to do processing on expiry of the UE delete timer
661 * This function processes the RLC UE delete timer expiry.
663 * @param[in] cb Pointer to the RlcUlUeCb
668 uint8_t rlcUeDeleteTmrExpiry(PTR cb)
670 RlcCb *gRlcCb = NULLP;
671 RlcCfgInfo *rlcUeCfg = NULLP;
672 RlcUlUeCb *ueCb = (RlcUlUeCb*)cb;
674 gRlcCb = RLC_GET_RLCCB(ueCb->ueDeleteInfo.pst.dstInst);
675 RLC_ALLOC(gRlcCb, rlcUeCfg, sizeof(RlcCfgInfo));
676 if(rlcUeCfg == NULLP)
678 DU_LOG("\nERROR --> RLC: rlcUeDeleteTmrExpiry(): Failed to allocate memory");
681 memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
682 fillRlcUeDelInfo(ueCb, rlcUeCfg);
683 if(RlcProcCfgReq(&ueCb->ueDeleteInfo.pst, rlcUeCfg) != ROK)
685 DU_LOG("\nERROR --> RLC: rlcUeDeleteTmrExpiry(): Failed to delete UE");
686 if(sendRlcUeDeleteRspToDu(rlcUeCfg->cellId, rlcUeCfg->ueId, INVALID_UEID) != ROK)
688 DU_LOG("ERROR --> RLC: rlcUeDeleteTmrExpiry(): Failed to send UE delete response ");
695 /********************************************************************30**
698 **********************************************************************/