Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_tmr.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /********************************************************************20**
20   
21         Name:    PDCP - TMR module file
22     
23         Type:    C source file
24   
25         Desc:    Source code for timer functions such as, 
26
27                  - pjStartTmr
28                  - pjStopTmr
29                  - pjTmrExpiry
30                  - pjHdlDiscTmrExp
31                  - pjHdlInitObdTmrExp 
32                  - pjHdlUeDelWaitTmrExp
33                   
34         File:    pj_tmr.c
35   
36 *********************************************************************21*/
37 static const char* RLOG_MODULE_NAME="PDCP";
38 static int RLOG_MODULE_ID=1024;
39 static int RLOG_FILE_ID=223;
40
41
42 /* header (.h) include files */
43 #include "envopt.h"        /* environment options */
44 #include "envdep.h"        /* environment dependent */
45 #include "envind.h"        /* environment independent */
46
47 #include "gen.h"           /* general */
48 #include "ssi.h"           /* system services */
49 #include "cm5.h"           /* common timer defines */
50 #include "cm_tkns.h"       /* common tokens defines */
51 #include "cm_mblk.h"       /* common memory allocation library defines */
52 #include "cm_llist.h"      /* common link list  defines  */
53 #include "cm_hash.h"       /* common hash list  defines */
54 #include "cm_lte.h"        /* common LTE defines */
55 #include "cpj.h"           /* RRC layer */
56 #include "pju.h"           /* PDCP service user */
57 #include "kwu.h"
58 #include "lpj.h"           /* LPJ defines */
59 #include "pj_env.h"        /* RLC environment options */
60 #include "pj.h"            /* RLC defines */
61 #include "pj_err.h"        /* Error defines */
62 #include "pj_udx.h"
63
64 /* extern (.x) include files */
65 #include "gen.x"           /* general */
66 #include "ssi.x"           /* system services */
67 #include "cm5.x"           /* common timer library */
68 #include "cm_tkns.x"       /* common tokens */
69 #include "cm_mblk.x"       /* common memory allocation */
70 #include "cm_llist.x"      /* common link list */
71 #include "cm_hash.x"       /* common hash list */
72 #include "cm_lte.x"        /* common LTE includes */
73 #include "cm_lib.x"        /* common memory allocation library */
74 #include "cpj.x"           /* RRC layer */
75 #include "kwu.x"
76 #include "pju.x"           /* PDCP service user */
77 #include "lpj.x"           /* LPJ */
78 #include "pj.x"
79 #include "pj_udx.h"
80 #include "pj_udx.x"
81 #include "pj_ul.x"
82 #include "pj_dl.x"
83
84 /* local defines */
85
86 /* local externs */
87
88 /* forward references */
89 PRIVATE Void pjBndTmrExpiry ARGS ((S16 tmrEvnt, PTR cb));
90 /* public variable declarations */
91
92 /* This structure holds all the global structs we need. */
93
94 /* private variable declarations */
95
96 /* private function declarations */
97 /** @file gp_pj_tmr.c
98 @brief PDCP Timer Module
99 **/
100
101 /**
102  * @def PJ_TMR_CALCUATE_WAIT
103  *
104  *    This macro calculates and assigns wait time based on the value of the 
105  *    timer and the timer resolution. Timer value of 0 signifies that the
106  *    timer is not configured
107  *
108  * @param[out] _wait   Time for which to arm the timer changed to proper 
109  *                     value according to the resolution
110  * @param[in] _tmrVal   Value of the timer
111  * @param[in] _timerRes   Resolution of the timer
112  *
113  */
114 #define PJ_TMR_CALCUATE_WAIT(_wait, _tmrVal, _timerRes)       \
115 {                                                             \
116       (_wait) = ((_tmrVal) * SS_TICKS_SEC)/((_timerRes) * 1000); \
117       if((0 != (_tmrVal)) && (0 == (_wait)))                     \
118       {                                                          \
119                (_wait) = 1;                                            \
120             }                                                          \
121 }
122
123 /**
124  *
125  * @brief Handler to start timer
126  *       
127  *
128  * @b Description
129  *        This function is invoked by DLM modules to start the discard timer for SDUs.
130  *
131  *
132  *  @param[in] cb      Transmission Buffer control block 
133  *  @param[in] tmrEvnt Timer event to be started
134  *
135  * 
136  *  @return  S16
137  *      -# ROK 
138  *      -# RFAILED 
139 */
140 #ifdef ANSI
141 PUBLIC S16 pjStartTmr
142 (
143 PjCb      *gCb,
144 PTR       cb,           /* Parent control block */
145 S16       tmrEvnt       /* Timer event */
146 )
147 #else
148 PUBLIC S16 pjStartTmr (gCb, cb, tmrEvnt) 
149 PjCb      *gCb;
150 PTR       cb;           /* Parent control block */
151 S16       tmrEvnt;      /* Timer event */
152 #endif
153 {
154 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
155    PjDlRbCb   *dlRbCb;
156    PjTxEnt  *txEnt;
157 #endif
158    U16      wait;
159    CmTimer  *tmr;
160    U8       maxTmrs;
161    CmTmrArg arg;
162    /* kw005.201 added support for L2 Measurement */
163 #ifdef LTE_L2_MEAS_COMMENT
164    PjL2MeasEvtCb *measEvtCb;
165 #endif
166
167 #ifdef LTE_L2_MEAS
168     PjL2Cb *pjL2Cb = NULLP;
169     PjCb   *tPjMeasCb = NULLP;
170 #endif
171    PjUlRbCb   *ulRbCb;
172
173    TRC2(pjStartTmr)
174
175    RLOG1(L_DEBUG, "pjStartTmr(cb, tmrEvnt (%d)) ", tmrEvnt);
176
177 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
178    ulRbCb  = NULLP; 
179    dlRbCb  = NULLP;
180    txEnt   = NULLP;
181
182
183 #endif
184    wait    = 0;
185    tmr     = NULLP;
186    maxTmrs = 0;
187
188    switch (tmrEvnt)
189    {
190       case PJ_EVT_WAIT_KWU_BNDCFM:
191       {
192          PjKwuSapCb *kwuSap = (PjKwuSapCb *)cb;
193          wait   = (U16)((kwuSap->bndTmrInt * SS_TICKS_SEC)/(gCb->pjGenCfg.timeRes * 1000));  /*KW_FIX*/
194          if( (0 != kwuSap->bndTmrInt) && (0 == wait) )
195          {
196             wait = 1;
197          }
198          tmr    = &kwuSap->bndTmr;
199          maxTmrs = PJ_MAX_KWUSAP_TMR;
200          break;
201       }
202       case PJ_EVT_WAIT_UDX_BNDCFM:
203       {
204          PjUdxUlSapCb *udxSap = (PjUdxUlSapCb *)cb;
205          wait   = (U16)((udxSap->bndTmrInt * SS_TICKS_SEC)/(gCb->pjGenCfg.timeRes * 1000));  /*KW_FIX*/
206          if( (0 != udxSap->bndTmrInt) && (0 == wait) )
207          {
208             wait = 1;
209          }
210          tmr    = &udxSap->bndTmr;
211          maxTmrs = PJ_MAX_UDXSAP_TMR;
212          break;
213       }    
214 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
215       case PJ_EVT_DL_OBD_TMR:
216       {
217          dlRbCb = (PjDlRbCb *)cb;
218          tmr=&(dlRbCb->dlCb.obdTmr);
219          maxTmrs = PJ_MAX_OBD_TMR;
220          txEnt = pjDbmGetTxEnt(gCb,&(dlRbCb->dlCb.txBuf), dlRbCb->dlCb.nxtToSub);
221          if ( txEnt != NULLP )
222          {
223             wait = gCb->pjGenCfg.obdTmrInt;
224             dlRbCb->dlCb.obdCount = txEnt->count;
225          }
226
227          break;
228       }
229       case PJ_EVT_UL_OBD_TMR:
230       {
231          ulRbCb = (PjUlRbCb *)cb;
232          tmr=&(ulRbCb->ulCb.obdTmr);
233          maxTmrs = PJ_MAX_OBD_TMR;
234          PJ_ULM_GET_SUBCNT(ulRbCb,(ulRbCb->ulCb.obdPdu),gCb);
235          if(pjDbmGetRxEnt(gCb,&(ulRbCb->ulCb.recBuf), ulRbCb->ulCb.obdPdu) != NULLP )
236          {
237             wait = gCb->pjGenCfg.obdTmrInt;
238          }
239
240          break;
241       } 
242       case PJ_EVT_OBD_WAIT_TMR:
243       {
244          if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL)
245          {
246             PjDlUeCb  *dlUeCb = (PjDlUeCb *)cb;
247             tmr=&(dlUeCb->libInfo.obdTmr);
248          }
249          else
250          {
251             PjUlUeCb  *ulUeCb = (PjUlUeCb *)cb;
252             tmr=&(ulUeCb->libInfo.obdTmr);
253          }
254          maxTmrs = PJ_MAX_OBD_TMR;
255          wait = gCb->pjGenCfg.obdWtTmrInt;
256          break;
257       }
258
259 #endif
260       /* kw005.201 added support for L2 Measurement */
261 #ifdef LTE_L2_MEAS_COMMENT
262       case PJ_EVT_L2_TMR:
263       {
264          measEvtCb = (PjL2MeasEvtCb *)cb;
265          tmr=&(measEvtCb->l2Tmr);
266          maxTmrs = PJ_L2_MAX_TIMERS;
267          wait = (measEvtCb->l2TmrCfg.val * SS_TICKS_SEC)/(pjCb.genCfg.timeRes * 1000);
268          if((measEvtCb->l2TmrCfg.val > 0) && wait == 0)
269          {
270             wait = 1;
271          }
272          break;
273       }
274 #endif
275 #ifdef LTE_L2_MEAS
276       case PJ_EVT_L2_MEAS_TMR:
277       {
278          tPjMeasCb = (PjCb      *)cb;
279          pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb;
280          tmr=&(pjL2Cb->measTmr);
281          maxTmrs = PJ_L2_MAX_TIMERS;
282          wait = (pjL2Cb->measTmrCfg.val * SS_TICKS_SEC)/(gCb->pjGenCfg.timeRes * 1000);
283          wait = 500;
284          if((pjL2Cb->measTmrCfg.val > 0) && wait == 0)
285          {
286             wait = 1;
287          }
288          break;
289       }
290 #endif
291      case PJ_EVT_UL_REORD_TMR:
292       {
293          ulRbCb = (PjUlRbCb *)cb;
294          tmr=&(ulRbCb->ulCb.tReordTmr);
295          maxTmrs = PJ_MAX_UL_REORD_TMRS;
296          PJ_TMR_CALCUATE_WAIT(wait, ulRbCb->reOrdrTmrVal, gCb->pjGenCfg.timeRes);
297          break;
298       }
299       default:
300       {
301          RLOG0(L_ERROR, "Invalid Start tmr Evnt");
302          RETVALUE(RFAILED);
303       }
304    } 
305
306    if(wait != 0)
307    {
308       arg.tqCp   = &gCb->pjTqCp;
309       arg.tq     = gCb->pjTq;
310       arg.cb     = cb;
311       arg.timers = tmr;
312       arg.evnt   = tmrEvnt;
313       arg.wait   = wait;
314       arg.tNum   = 0;
315       arg.max    = maxTmrs;
316
317       cmPlcCbTq(&arg);
318    }
319
320    RETVALUE(ROK);
321 }
322
323 /**
324  *
325  * @brief Handler to stop timer
326  *       
327  *
328  * @b Description
329  *        This function is used to stop protocol timer, based on the timer event.
330  *
331  *
332  *  @param[in] cb      Transmission Buffer control block 
333  *  @param[in] tmrEvnt Timer event to be started 
334  *
335  * 
336  *  @return  S16
337  *      -# ROK 
338  *      -# RFAILED 
339 */
340 #ifdef ANSI
341 PUBLIC S16 pjStopTmr
342 (
343 PjCb   *gCb,
344 PTR    cb,              /* Parent control block */
345 U8     tmrEvnt          /* Timer */
346 )
347 #else
348 PUBLIC S16 pjStopTmr (gCb, cb, tmrEvnt) 
349 PjCb   *gCb;
350 PTR    cb;              /* Parent control block */
351 U8     tmrEvnt;         /* Timer */
352 #endif
353 {
354    CmTmrArg     arg;
355    CmTimer      *tmr;
356 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
357    PjDlRbCb     *pjDlRbCb;
358 #endif
359    PjKwuSapCb   *kwuSap;
360    PjUdxUlSapCb   *udxSap;
361 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
362    PjDlUeCb       *dlUeCb;
363    PjUlUeCb       *ulUeCb;
364 #endif
365    /* kw005.201 added support for L2 Measurement */
366 #ifdef LTE_L2_MEAS
367    PjL2Cb *pjL2Cb = NULLP;
368    PjCb   *tPjMeasCb = NULLP;
369 #endif
370    U8           maxTimers;
371    PjUlRbCb     *pjUlRbCb;
372
373    TRC2(pjStopTmr)
374    
375    RLOG1(L_DEBUG, "pjStopTmr(cb, tmrEvnt(%d)) ", tmrEvnt);
376    
377    tmr = NULLP;
378    maxTimers = 0;
379 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
380    pjUlRbCb = NULLP;
381    pjDlRbCb    = NULLP;
382    /* ueCb   = NULLP; */
383 #endif
384
385    switch (tmrEvnt)
386    {
387       case PJ_EVT_WAIT_KWU_BNDCFM:
388       {
389          kwuSap = (PjKwuSapCb *)cb;
390          tmr = &kwuSap->bndTmr;
391          arg.max = PJ_MAX_KWUSAP_TMR;
392          break;
393       }
394       case PJ_EVT_WAIT_UDX_BNDCFM:
395       {
396          udxSap = (PjUdxUlSapCb *)cb;
397          tmr = &udxSap->bndTmr;
398          arg.max = PJ_MAX_UDXSAP_TMR;
399          break;
400       }
401 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
402       case PJ_EVT_DL_OBD_TMR:
403       {
404          pjDlRbCb = (PjDlRbCb *)cb;
405          tmr = &(pjDlRbCb->dlCb.obdTmr);
406          maxTimers = PJ_MAX_OBD_TMR;
407          break;
408       }
409       case PJ_EVT_UL_OBD_TMR:
410       {
411          pjUlRbCb = (PjUlRbCb *)cb;
412          tmr = &(pjUlRbCb->ulCb.obdTmr);
413          maxTimers = PJ_MAX_OBD_TMR;
414          break;
415       }
416       case PJ_EVT_OBD_WAIT_TMR:
417       {
418          /*if (gCb->pjGenCfg.mode == LPJ_PDCP_MODE_DL)*/
419          if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL)
420          {
421             dlUeCb = (PjDlUeCb *)cb;
422             tmr  = &(dlUeCb->libInfo.obdTmr);
423          }
424          else
425          {
426             ulUeCb = (PjUlUeCb *)cb;
427             tmr  = &(ulUeCb->libInfo.obdTmr);
428          }
429          maxTimers = PJ_MAX_OBD_TMR;
430          break;
431       }
432
433 #endif
434      /* kw005.201 added support for L2 Measurement */
435 #ifdef LTE_L2_MEAS_COMMENT
436       case PJ_EVT_L2_TMR:
437       {
438          measEvtCb = (PjL2MeasEvtCb *)cb;
439          tmr  = &(measEvtCb->l2Tmr);
440          maxTimers = PJ_L2_MAX_TIMERS;
441          break;
442       }
443 #endif
444 #ifdef LTE_L2_MEAS
445       case PJ_EVT_L2_MEAS_TMR:
446       {
447          tPjMeasCb = (PjCb      *)cb;
448          pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb;
449          tmr  = &(pjL2Cb->measTmr);
450          maxTimers = PJ_L2_MAX_TIMERS;
451          break;
452       }
453 #endif
454      case PJ_EVT_UL_REORD_TMR:
455       {
456          pjUlRbCb = (PjUlRbCb *)cb;
457          tmr=&(pjUlRbCb->ulCb.tReordTmr);
458          maxTimers = PJ_MAX_UL_REORD_TMRS;
459          break;
460       }
461       default:
462       {
463          RLOG0(L_ERROR, "Invalid Stop tmr Evnt");
464          RETVALUE(RFAILED);
465       }
466    }
467    
468    
469    if (tmrEvnt != TMR0)
470    {
471       arg.tqCp    = &gCb->pjTqCp;
472       arg.tq      = gCb->pjTq;
473       arg.cb      = (PTR)cb;
474       arg.timers  = tmr;
475       arg.evnt    = tmrEvnt;
476       arg.wait    = 0;
477       arg.max     = maxTimers;
478       arg.tNum    = 0;
479       cmRmvCbTq(&arg);
480
481    }
482    
483    RETVALUE(ROK);
484 }
485
486 /**
487  *
488  * @brief Handler to invoke events on expiry of timer.
489  *       
490  *
491  * @b Description
492  *        This function is used to handle expiry of timer,it invokes relevant functions.
493  *
494  *
495  *  @param[in] cb        Transmission Buffer control block 
496  *  @param[in] tmrType   Type of the timer to be stopped
497  *
498  * 
499  *  @return  S16
500  *      -# ROK 
501  *      -# RFAILED 
502 */
503 #ifdef ANSI
504 PUBLIC S16 pjTmrExpiry
505 (
506 PTR       cb,           /* Parent control block */
507 S16       tmrEvnt       /* Timer event */
508 )
509 #else
510 PUBLIC S16 pjTmrExpiry (cb, tmrEvnt)
511 PTR       cb;           /* Parent control block */
512 S16       tmrEvnt;      /* Timer event */
513 #endif
514 {
515 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
516    PjDlRbCb      *dlRbCb        = NULLP;
517    PjDlUeCb      *dlUeCb          = NULLP;
518    PjUlUeCb      *ulUeCb          = NULLP;
519 #endif 
520    PjUlRbCb      *ulRbCb        = NULLP; 
521 #ifdef LTE_L2_MEAS
522    PjL2Cb *pjL2Cb = NULLP;
523    PjCb   *tPjMeasCb = NULLP;
524 #endif
525    /* pj005.201 added support for L2 Measurement */
526    TRC2(pjTmrExpiry)
527
528   switch (tmrEvnt)
529    {
530       case PJ_EVT_WAIT_KWU_BNDCFM:
531       {
532          pjBndTmrExpiry(tmrEvnt,cb);
533          /* kw005.201 added missing break statement */
534          break;
535       }
536       case PJ_EVT_WAIT_UDX_BNDCFM:
537       {
538          pjBndTmrExpiry(tmrEvnt,cb);
539          /* kw005.201 added missing break statement */
540          break;
541       }
542 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
543       case PJ_EVT_DL_OBD_TMR:
544       {
545          PjCb *tPjCb;
546          dlRbCb = (PjDlRbCb *)cb;
547
548          if (dlRbCb->ueCb->inst >= PJ_MAX_PDCP_INSTANCES)
549          {
550             RETVALUE(RFAILED);
551          }
552          tPjCb = PJ_GET_PJCB(dlRbCb->ueCb->inst);
553
554          pjDlmObdTmrExp(tPjCb,dlRbCb);
555          break;
556       }
557       case PJ_EVT_UL_OBD_TMR:
558       {
559          PjCb *tPjCb;
560          ulRbCb = (PjUlRbCb *)cb;
561
562          if (ulRbCb->ueCb->inst >= PJ_MAX_PDCP_INSTANCES)
563          {
564             RETVALUE(RFAILED);
565          }
566          tPjCb = PJ_GET_PJCB(ulRbCb->ueCb->inst);
567           pjUlmHdlObdTmrExpiry(tPjCb,ulRbCb);
568          break;
569       }
570       case PJ_EVT_OBD_WAIT_TMR:
571       {
572          PjCb *tPjCb;
573          tPjCb = (PjCb*)cb;
574          if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
575          {
576             ulUeCb = (PjUlUeCb *)cb;
577             if (ulUeCb->inst >= PJ_MAX_PDCP_INSTANCES)
578             {
579                 RETVALUE(RFAILED);
580             }
581             tPjCb = PJ_GET_PJCB(ulUeCb->inst);
582             pjUtlUlHdlInitObdTmrExp(tPjCb,ulUeCb);
583             
584          }
585          else
586          {
587              dlUeCb = (PjDlUeCb *)cb;
588              if (dlUeCb->inst >= PJ_MAX_PDCP_INSTANCES)
589              {
590                  RETVALUE(RFAILED);
591              }
592              tPjCb = PJ_GET_PJCB(dlUeCb->inst);
593              pjUtlDlHdlInitObdTmrExp(tPjCb,dlUeCb);
594          }
595          break;
596       }
597
598 #endif
599 #ifdef LTE_L2_MEAS
600       case PJ_EVT_L2_MEAS_TMR:
601       {
602          tPjMeasCb = (PjCb      *)cb;
603          pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb;
604          pjUtlMemCpuHdlTmrExp((PjCb *)cb,pjL2Cb);
605       }
606       break;
607 #endif
608      case PJ_EVT_UL_REORD_TMR:
609       {
610          PjCb *tPjCb;
611          ulRbCb = (PjUlRbCb *)cb;
612          if (ulRbCb->ueCb->inst >= PJ_MAX_PDCP_INSTANCES)
613          {
614             RETVALUE(RFAILED);
615          }
616          tPjCb = PJ_GET_PJCB(ulRbCb->ueCb->inst);
617          pjUlmHdlReordTmrExpiry(tPjCb, ulRbCb);
618          break;
619       }
620       /* pj005.201 added support for L2 Measurement */
621       default:
622       {
623          RETVALUE(RFAILED);
624       }
625    }
626
627    RETVALUE(ROK);
628 }
629
630 /**
631  *
632  * @brief Handler to check if the timer is running
633  *       
634  *
635  * @b Description
636  *        This function is used to check if the timer is running at the given
637  *        moment.
638  *
639  *
640  *  @param[in] cb      Transmission Buffer control block 
641  *  @param[in] tmrType   Type of the timer to be stopped 
642  *
643  * 
644  *  @return  S16
645  *      -# ROK 
646  *      -# RFAILED 
647  */
648 #ifdef ANSI
649 PUBLIC Bool pjChkTmr
650 (
651 PjCb      *gCb,
652 PTR       cb,           /* Parent control block */
653 S16       tmrEvnt       /* Timer event */
654 )
655 #else
656 PUBLIC Bool pjChkTmr(gCb, cb, tmrEvnt) 
657 PjCb      *gCb;
658 PTR       cb;           /* Parent control block */
659 S16       tmrEvnt;      /* Timer event */
660 #endif
661 {
662 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
663    PjDlUeCb  *dlUeCb         = NULLP;
664    PjUlUeCb  *ulUeCb         = NULLP;
665 #endif
666 #ifdef LTE_L2_MEAS
667    PjL2Cb *pjL2Cb = NULLP;
668    PjCb   *tPjMeasCb = NULLP;
669 #endif
670    Bool tmrRunning = FALSE;
671    PjUlRbCb  *ulRbCb         = NULLP;
672
673    TRC2(pjChkTmr)
674
675    RLOG1(L_UNUSED, "pjChkTmr(cb, tmrEvnt(%d)) ", tmrEvnt);
676
677    switch (tmrEvnt)
678    {
679 #if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC))
680       case PJ_EVT_DL_OBD_TMR:
681       {
682          dlRbCb = (PjDlRbCb *)cb;
683          if (dlRbCb->dlCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR)
684          {
685             tmrRunning = TRUE;
686          }
687          break;
688       }
689       case PJ_EVT_UL_OBD_TMR:
690       {
691           ulRbCb = (PjUlRbCb *)cb;
692           if (ulRbCb->ulCb.obdTmr.tmrEvnt == PJ_EVT_UL_OBD_TMR)
693           {
694               tmrRunning = TRUE;
695           }
696           break;
697       }
698       case PJ_EVT_OBD_WAIT_TMR:
699       {
700           if(gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
701           {
702               ulUeCb = (PjUlUeCb *)cb;
703               if (ulUeCb->inst >= PJ_MAX_PDCP_INSTANCES)
704               {
705                   RETVALUE(RFAILED);
706               }
707               if (ulUeCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_WAIT_TMR)
708               {
709                   tmrRunning = TRUE;
710               }
711           }
712           else
713           {
714               dlUeCb = (PjDlUeCb *)cb;
715               if (dlUeCb->inst >= PJ_MAX_PDCP_INSTANCES)
716               {
717                   RETVALUE(RFAILED);
718               }
719               if (dlUeCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_WAIT_TMR)
720               {
721                   tmrRunning =  TRUE;
722               }
723           }
724           break;
725       }
726 #endif
727 #ifdef LTE_L2_MEAS
728       case PJ_EVT_L2_MEAS_TMR:
729       {
730          tPjMeasCb = (PjCb      *)cb;
731          pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb;
732          if (pjL2Cb->measTmr.tmrEvnt == PJ_EVT_L2_MEAS_TMR)
733          {
734              tmrRunning = TRUE;
735          }
736          break;
737       }
738 #endif
739       case PJ_EVT_UL_REORD_TMR:
740       {
741          ulRbCb = (PjUlRbCb *)cb;
742          if(PJ_EVT_UL_REORD_TMR == ulRbCb->ulCb.tReordTmr.tmrEvnt)
743          {
744              tmrRunning = TRUE;
745          }
746          break;
747       }
748       default:
749       {
750
751           RLOG0(L_ERROR, "Invalid Chk tmr Evnt");
752           RETVALUE(RFAILED);
753       }
754    } 
755
756    RETVALUE(tmrRunning);
757 }
758 /**
759  *
760  * @brief Private handler to invoke an event for bind timer expiry
761  *       
762  *
763  * @b Description
764  *        This function processes the RLC bind timer expiry. If the number of retry is
765  *        less than the maximum retry counter, bind request is sent again, else an 
766  *        alarm is raised to the layer manager.
767  *
768  *
769  *  @param[in] cb      RB control block 
770  *
771  * 
772  *   @return Void
773  *      -# RETVOID
774 */
775 #ifdef ANSI
776 PRIVATE Void pjBndTmrExpiry
777 (
778 S16       tmrEvnt,
779 PTR       cb            /* Parent control block */
780 )
781 #else
782 PRIVATE Void pjBndTmrExpiry(tmrEvnt, cb) 
783 S16       tmrEvnt;
784 PTR       cb;           /* Parent control block */
785 #endif
786 {
787    PjCb          *tPjCb;
788    PjUdxUlSapCb  *udxSap;
789    PjKwuSapCb *kwuSapCb; 
790
791    TRC2(pjBndTmrExpiry)
792
793    if (tmrEvnt == PJ_EVT_WAIT_KWU_BNDCFM)
794    {
795       kwuSapCb = (PjKwuSapCb *) cb;
796
797       tPjCb = PJ_GET_PJCB(kwuSapCb->pst.srcInst);
798       if (kwuSapCb->state == PJ_SAP_BINDING)
799       {
800          if (kwuSapCb->retryCnt < PJ_MAX_SAP_BND_RETRY)
801          {
802             /* Send bind request */
803             kwuSapCb->retryCnt++;
804
805             /* start timer to wait for bind confirm */
806             pjStartTmr(tPjCb, (PTR)kwuSapCb, PJ_EVT_WAIT_KWU_BNDCFM);
807
808             PjLiKwuBndReq (&kwuSapCb->pst, kwuSapCb->suId, kwuSapCb->spId);
809          }
810          else
811          {
812             kwuSapCb->retryCnt = 0;
813             kwuSapCb->state = PJ_SAP_CFG;
814
815             /* Send alarm to the layer manager */
816 #ifdef LTE_L2_MEAS
817             pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
818                            LCM_CAUSE_TMR_EXPIRED, 0, 0, 0);
819 #else
820             pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
821                            LCM_CAUSE_TMR_EXPIRED, 0, 0);
822 #endif
823          }
824       }
825    }
826    else
827    {
828       udxSap = (PjUdxUlSapCb *)cb;
829
830       tPjCb  = PJ_GET_PJCB (udxSap->pst.srcInst);
831
832       if (udxSap->state == PJ_SAP_BINDING)
833       {
834          if (udxSap->retryCnt < PJ_MAX_SAP_BND_RETRY)
835          {
836             /* Send bind request */
837             udxSap->retryCnt++;
838
839             /* start timer to wait for bind confirm */
840             pjStartTmr(tPjCb, (PTR)udxSap, PJ_EVT_WAIT_UDX_BNDCFM);
841
842             PjUlUdxBndReq (&udxSap->pst, udxSap->suId, udxSap->spId);
843          }
844          else
845          {
846             udxSap->retryCnt = 0;
847             udxSap->state = PJ_SAP_CFG;
848
849             /* Send alarm to the layer manager */
850 #ifdef LTE_L2_MEAS
851             pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
852                            LCM_CAUSE_TMR_EXPIRED, 0, 0, 0);
853 #else
854             pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL,
855                            LCM_CAUSE_TMR_EXPIRED, 0, 0);
856 #endif
857          }
858       }
859
860    }
861
862    RETVOID;
863 }
864
865
866 \f  
867 /********************************************************************30**
868   
869          End of file
870 **********************************************************************/