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*/
35 static const char* RLOG_MODULE_NAME="TMR";
36 static int RLOG_MODULE_ID=2048;
37 static int RLOG_FILE_ID=202;
40 /* header (.h) include files */
41 #include "envopt.h" /* environment options */
42 #include "envdep.h" /* environment dependent */
43 #include "envind.h" /* environment independent */
45 #include "gen.h" /* general */
46 #include "ssi.h" /* system services */
47 #include "cm5.h" /* common timer defines */
48 #include "cm_tkns.h" /* common tokens defines */
49 #include "cm_mblk.h" /* common memory allocation library defines */
50 #include "cm_llist.h" /* common link list defines */
51 #include "cm_hash.h" /* common hash list defines */
52 #include "cm_lte.h" /* common LTE defines */
53 #include "lkw.h" /* LKW defines */
54 #include "ckw.h" /* CKW defines */
55 #include "kwu.h" /* KWU defines */
56 #include "rgu.h" /* RGU defines */
57 #include "kw_env.h" /* RLC environment options */
59 #include "kw.h" /* RLC defines */
60 #include "kw_err.h" /* Error defines */
65 /* extern (.x) include files */
66 #include "gen.x" /* general */
67 #include "ssi.x" /* system services */
68 #include "cm5.x" /* common timer library */
69 #include "cm_tkns.x" /* common tokens */
70 #include "cm_mblk.x" /* common memory allocation */
71 #include "cm_llist.x" /* common link list */
72 #include "cm_hash.x" /* common hash list */
73 #include "cm_lte.x" /* common LTE includes */
74 #include "cm_lib.x" /* common memory allocation library */
75 #include "lkw.x" /* LKW */
76 #include "ckw.x" /* CKW */
77 #include "kwu.x" /* KWU */
78 #include "rgu.x" /* RGU */
87 * @brief RLC Timer Module
91 * @def KW_TMR_CALCUATE_WAIT
93 * This macro calculates and assigns wait time based on the value of the
94 * timer and the timer resolution. Timer value of 0 signifies that the
95 * timer is not configured
97 * @param[out] _wait Time for which to arm the timer changed to proper
98 * value according to the resolution
99 * @param[in] _tmrVal Value of the timer
100 * @param[in] _timerRes Resolution of the timer
103 #define KW_TMR_CALCUATE_WAIT(_wait, _tmrVal, _timerRes) \
105 (_wait) = ((_tmrVal) * SS_TICKS_SEC)/((_timerRes) * 1000); \
106 if((0 != (_tmrVal)) && (0 == (_wait))) \
112 /* private function declarations */
113 PRIVATE Void kwBndTmrExpiry(PTR cb);
116 * @brief Handler to start timer
118 * @param[in] gCb Pointer to the RLC instance control block
119 * @param[in] cb Control block depending on the type of the timer event.
120 * It can be uplink/downlink rbCb or rgu sap control block
121 * @param[in] tmrEvnt Timer event to be started
126 PUBLIC Void kwStartTmr
133 PUBLIC Void kwStartTmr (gCb,cb, tmrEvnt)
139 /* kw005.201 added support for L2 Measurement */
141 KwL2MeasEvtCb *measEvtCb = NULLP;
149 /* kw002.201 Adjusting the wait time as per timeRes configured by layer manager */
152 case KW_EVT_UMUL_REORD_TMR:
154 KwUmUl* umUl = &(((KwUlRbCb *)cb)->m.umUl);
155 /* kw005.201 Changed wait calculation ccpu00117634*/
156 KW_TMR_CALCUATE_WAIT(arg.wait, umUl->reOrdTmrInt, gCb->genCfg.timeRes);
158 arg.timers = &umUl->reOrdTmr;
159 arg.max = KW_MAX_UM_TMR;
162 case KW_EVT_AMUL_REORD_TMR:
164 KwAmUl* amUl = &(((KwUlRbCb *)cb)->m.amUl);
165 /* kw005.201 Changed wait calculation ccpu00117634*/
166 KW_TMR_CALCUATE_WAIT(arg.wait, amUl->reOrdTmrInt, gCb->genCfg.timeRes);
168 arg.timers = &amUl->reOrdTmr;
169 arg.max = KW_MAX_AM_TMR;
172 case KW_EVT_AMUL_STA_PROH_TMR:
174 KwAmUl* amUl = &(((KwUlRbCb *)cb)->m.amUl);
175 /* kw005.201 Changed wait calculation ccpu00117634*/
176 KW_TMR_CALCUATE_WAIT(arg.wait,
178 gCb->genCfg.timeRes);
180 arg.timers = &amUl->staProhTmr;
181 arg.max = KW_MAX_AM_TMR;
184 case KW_EVT_AMDL_POLL_RETX_TMR:
186 KwAmDl* amDl = &(((KwDlRbCb *)cb)->m.amDl);
187 /* kw005.201 Changed wait calculation ccpu00117634*/
188 KW_TMR_CALCUATE_WAIT(arg.wait,
189 amDl->pollRetxTmrInt,
190 gCb->genCfg.timeRes);
192 arg.timers = &amDl->pollRetxTmr;
193 arg.max = KW_MAX_AM_TMR;
196 case KW_EVT_WAIT_BNDCFM:
198 KwRguSapCb* rguSap = (KwRguSapCb *)cb;
199 /* kw005.201 Changed wait calculation ccpu00117634*/
200 KW_TMR_CALCUATE_WAIT(arg.wait, rguSap->bndTmrInt, gCb->genCfg.timeRes);
202 arg.timers = &rguSap->bndTmr;
203 arg.max = KW_MAX_RGUSAP_TMR;
206 /* kw005.201 added support for L2 Measurement */
210 measEvtCb = (KwL2MeasEvtCb *)cb;
211 /* kw005.201 Changed wait calculation ccpu00117634*/
212 KW_TMR_CALCUATE_WAIT(arg.wait,
213 measEvtCb->l2TmrCfg.val,
214 gCb->genCfg.timeRes);
216 arg.timers = &measEvtCb->l2Tmr;
217 arg.max = KW_L2_MAX_TIMERS;
223 RLOG0(L_ERROR, "Invalid tmr Evnt");
229 arg.tqCp = &gCb->kwTqCp;
242 * @brief Handler to stop a timer
244 * @param[in] gCb Pointer to the RLC instance control block
245 * @param[in] cb Control block depending on the type of the timer event.
246 * It can be uplink/downlink rbCb or rgu sap control block
247 * @param[in] tmrType Timer event to be started
252 PUBLIC Void kwStopTmr
259 PUBLIC Void kwStopTmr (gCb, cb, tmrType)
266 /* kw005.201 added support for L2 Measurement */
268 KwL2MeasEvtCb *measEvtCb = NULLP;
276 case KW_EVT_UMUL_REORD_TMR:
278 arg.timers = &((KwUlRbCb *)cb)->m.umUl.reOrdTmr;
279 arg.max = KW_MAX_UM_TMR;
282 case KW_EVT_AMUL_REORD_TMR:
284 arg.timers = &((KwUlRbCb *)cb)->m.amUl.reOrdTmr;
285 arg.max = KW_MAX_AM_TMR;
288 case KW_EVT_AMUL_STA_PROH_TMR:
290 arg.timers = &((KwUlRbCb *)cb)->m.amUl.staProhTmr;
291 arg.max = KW_MAX_AM_TMR;
294 case KW_EVT_AMDL_POLL_RETX_TMR:
296 arg.timers = &((KwDlRbCb *)cb)->m.amDl.pollRetxTmr;
297 arg.max = KW_MAX_AM_TMR;
300 case KW_EVT_WAIT_BNDCFM:
302 arg.timers = &((KwRguSapCb *)cb)->bndTmr;
303 arg.max = KW_MAX_RGUSAP_TMR;
306 /* kw005.201 added support for L2 Measurement */
310 measEvtCb = (KwL2MeasEvtCb *)cb;
311 arg.timers = &measEvtCb->l2Tmr;
312 arg.max = KW_L2_MAX_TIMERS;
318 RLOG0(L_ERROR, "Invalid tmr Evnt");
323 arg.tqCp = &gCb->kwTqCp;
336 * @brief Handler to invoke events on expiry of timer.
339 * This function is used to handle expiry of timer,it invokes relevant
342 * @param[in] cb Control block depending on the type of the timer event.
343 * It can be uplink/downlink rbCb or rgu sap control block
344 * @param[in] tmrEvnt Timer event to be started
349 PUBLIC Void kwTmrExpiry
355 PUBLIC Void kwTmrExpiry (cb, tmrEvnt)
360 /* kw005.201 added support for L2 Measurement */
365 case KW_EVT_UMUL_REORD_TMR:
367 KwUlRbCb *ulRbCb = (KwUlRbCb *)cb;
368 kwUmmReOrdTmrExp(KW_GET_KWCB(ulRbCb->inst), ulRbCb);
372 case KW_EVT_AMUL_REORD_TMR:
374 KwUlRbCb *ulRbCb = (KwUlRbCb *)cb;
375 kwAmmReOrdTmrExp(KW_GET_KWCB(ulRbCb->inst), ulRbCb);
378 case KW_EVT_AMUL_STA_PROH_TMR:
380 KwUlRbCb *ulRbCb = (KwUlRbCb *)cb;
381 kwAmmStaProTmrExp(KW_GET_KWCB(ulRbCb->inst), ulRbCb);
385 case KW_EVT_AMDL_POLL_RETX_TMR:
387 KwDlRbCb *dlRbCb = (KwDlRbCb *)cb;
388 KwCb *gCb = KW_GET_KWCB(dlRbCb->inst);
390 kwAmmPollRetxTmrExp(gCb, dlRbCb);
392 gCb->genSts.protTimeOut++;
395 case KW_EVT_WAIT_BNDCFM:
400 /* kw005.201 L2 Measurement support */
411 * @brief Handler to check if the timer is running
413 * @param[in] gCb Pointer to the RLC instance control block
414 * @param[in] cb Control block depending on the type of the timer event.
415 * It can be uplink/downlink rbCb or rgu sap control block
416 * @param[in] tmrEvnt Timer event to be started
418 * @return Bool indicating whether the timer is running or not
430 PUBLIC Bool kwChkTmr(gCb,cb, tmrEvnt)
440 case KW_EVT_UMUL_REORD_TMR:
442 return (((KwUlRbCb *)cb)->m.umUl.reOrdTmr.tmrEvnt ==
443 KW_EVT_UMUL_REORD_TMR);
445 case KW_EVT_AMUL_REORD_TMR:
447 return (((KwUlRbCb *)cb)->m.amUl.reOrdTmr.tmrEvnt ==
448 KW_EVT_AMUL_REORD_TMR);
450 case KW_EVT_AMUL_STA_PROH_TMR:
452 return (((KwUlRbCb *)cb)->m.amUl.staProhTmr.tmrEvnt ==
453 KW_EVT_AMUL_STA_PROH_TMR);
455 case KW_EVT_AMDL_POLL_RETX_TMR:
457 return (((KwDlRbCb *)cb)->m.amDl.pollRetxTmr.tmrEvnt ==
458 KW_EVT_AMDL_POLL_RETX_TMR);
460 case KW_EVT_WAIT_BNDCFM:
462 return (((KwRguSapCb *)cb)->bndTmr.tmrEvnt == KW_EVT_WAIT_BNDCFM);
466 RLOG0(L_ERROR, "Invalid tmr Evnt");
474 * @brief Handler to do processing on expiry of the bind timer
477 * This function processes the RLC bind timer expiry. If the number of
478 * retries is less than the maximum retry counter, bind request is sent
479 * again, else an alarm is raised to the layer manager.
481 * @param[in] cb Pointer to the Rgu sap
486 PRIVATE Void kwBndTmrExpiry
491 PRIVATE Void kwBndTmrExpiry(cb)
495 KwRguSapCb *rguSapCb;
499 rguSapCb = (KwRguSapCb *) cb;
501 if (rguSapCb->state == KW_SAP_BINDING)
503 if (rguSapCb->retryCnt < KW_MAX_SAP_BND_RETRY)
505 /* start timer to wait for bind confirm */
506 kwStartTmr(KW_GET_KWCB(rguSapCb->pst.srcInst),
510 /* Send bind request */
511 rguSapCb->retryCnt++;
512 KwLiRguBndReq (&rguSapCb->pst, rguSapCb->suId, rguSapCb->spId);
516 rguSapCb->retryCnt = 0;
517 rguSapCb->state = KW_SAP_CFG;
519 /* Send alarm to the layer manager */
521 kwLmmSendAlarm(KW_GET_KWCB(rguSapCb->pst.srcInst),
522 LCM_CATEGORY_INTERFACE,
524 LCM_CAUSE_TMR_EXPIRED,
529 kwLmmSendAlarm(KW_GET_KWCB(rguSapCb->pst.srcInst),
530 LCM_CATEGORY_INTERFACE,
532 LCM_CAUSE_TMR_EXPIRED,
544 /********************************************************************30**
547 **********************************************************************/