[Epic-ID: ODUHIGH-510][Task-ID: ODUHIGH-512] Implementation of E2 setup failure
[o-du/l2.git] / src / du_app / du_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 #include "common_def.h"
20 #include "lkw.h"
21 #include "lkw.x"
22 #include "lrg.h"
23 #include "lrg.x"
24 #include "du_tmr.h"
25 #include "du_app_rlc_inf.h"
26 #include "du_app_mac_inf.h"
27 #include "du_cfg.h"
28 #include "du_e2ap_mgr.h"
29 #include "du_mgr.h"
30 #include "du_e2ap_msg_hdl.h"
31
32 /**
33  * @brief Handler to check if the timer is running
34  *
35  * @param[in] cb        Control block depending on the type of the timer event.
36  *                      It can be uplink/downlink rbCb or rgu sap control block
37  * @param[in] tmrEvnt   Timer event to be started
38  *
39  * @return  Bool indicating whether the timer is running or not
40  *      -# ROK
41  *      -# RFAILED
42 */
43
44 bool duChkTmr(PTR cb, int16_t tmrEvnt)
45 {
46    switch (tmrEvnt)
47    {
48       case EVENT_E2_SETUP_TMR:
49       {
50          if(((E2apDb *)cb)->e2Timers.e2SetupTimer.tmrEvnt == EVENT_E2_SETUP_TMR)
51          {
52              DU_LOG("\nERROR  -->  DU_APP : duChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
53              return TRUE;
54          }
55       }
56       
57       default:
58       {
59          DU_LOG("\nERROR  -->  DU_APP : duChkTmr: Invalid tmr Evnt [%d]", tmrEvnt);
60       }
61    }
62
63    return FALSE;
64 }
65
66 /**
67  * @brief Handler to start timer
68  *
69  * @param[in] cb        Control block depending on the type of the timer event.
70  *                      It can be uplink/downlink rbCb or rgu sap control block
71  * @param[in] tmrEvnt   Timer event to be started
72  *
73  * @return  Void
74 */
75
76 void duStartTmr(PTR cb, int16_t tmrEvnt, uint8_t timerValue)
77 {
78    E2apDb *e2apDb;
79    CmTmrArg arg;
80    arg.wait = 0;
81    
82    switch (tmrEvnt)
83    {
84       case EVENT_E2_SETUP_TMR:
85       {
86          e2apDb = ((E2apDb *)cb);
87          DU_TMR_CALCUATE_WAIT(arg.wait, timerValue, duCb.duTimersInfo.tmrRes);
88
89          arg.timers = &e2apDb->e2Timers.e2SetupTimer;
90          arg.max = MAX_E2_SETUP_TMR;
91          break;
92       }
93       default:
94       {
95          DU_LOG("\nERROR  -->  DU : duStartTmr: Invalid tmr Evnt [%d]", tmrEvnt);
96       }
97    }
98
99    if(arg.wait != 0)
100    {
101       arg.tqCp   = &(duCb.duTimersInfo.tmrTqCp);
102       arg.tq     = duCb.duTimersInfo.tmrTq;
103       arg.cb     = cb;
104       arg.evnt   = tmrEvnt;
105       arg.tNum   = 0;
106
107       cmPlcCbTq(&arg);
108    }
109    return;
110 }
111
112 /**
113  * @brief Handler to invoke events on expiry of timer.
114  *
115  * @details
116  *    This function is used to handle expiry of timer,it invokes relevant
117  *    functions.
118  *
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
122  *
123  * @return  Void
124 */
125
126 void duTmrExpiry(PTR cb,int16_t tmrEvnt)
127 {
128    switch (tmrEvnt)
129    {
130       case EVENT_E2_SETUP_TMR:
131       {
132          BuildAndSendE2SetupReq();
133          break;
134       }
135       default:
136       {
137          DU_LOG("\nERROR  -->  DU : duStartTmr: Invalid tmr Evnt [%d]", tmrEvnt);
138          break;
139       }
140    }
141
142    return;
143 }
144
145 /**
146  * @brief DU instance timer call back function registered with system services.
147  *
148  * @details
149  *
150  *     Function :  duActvTmr
151  *
152  *     This function is invoked for every timer activation
153  *     period expiry. Note that SS_MT_TMR flag needs to be enabled for this
154  *     as isntId is needed.As part of SRegTmr call for du instance
155  *     SS_MT_TMR flag needs to be enabled and duActvTmr needs to be given as
156  *     callback function
157  *
158  *  @return  short int
159  *      -# ROK
160  **/
161
162 short int duActvTmr(Ent ent,Inst inst)
163 {
164    /* Check if any timer in the du instance has expired */
165    cmPrcTmr(&(duCb.duTimersInfo.tmrTqCp), duCb.duTimersInfo.tmrTq, (PFV) duTmrExpiry);
166
167    return ROK;
168
169 } /* end of duActvTmr */
170
171 /**********************************************************************
172
173          End of file
174 **********************************************************************/
175