warning set 3: fixed warning realted to unused-variable and implicit-function-declaration
[o-du/l2.git] / src / du_app / du_mgr_ex_ms.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 /* This file contains message handling functionality for DU APP */
20
21 #include "du_sctp.h"
22 #include "du_f1ap_msg_hdl.h"
23 #include "du_e2ap_msg_hdl.h"
24 #include "lsctp.h"
25 #include "legtp.h"
26 #include "du_app_mac_inf.h"
27 #include "du_ue_mgr.h"
28 #include "kwu.x"
29
30 extern S16 cmUnpkLkwCfgCfm(LkwCfgCfm func,Pst *pst, Buffer *mBuf);
31 extern S16 cmUnpkLkwCntrlCfm(LkwCntrlCfm func,Pst *pst, Buffer *mBuf);
32 extern S16 cmUnpkLrgCfgCfm(LrgCfgCfm func,Pst *pst, Buffer *mBuf);
33 extern S16 cmUnpkKwuDatInd(KwuDatInd func,Pst *pst, Buffer *mBuf);
34 extern S16 cmUnpkLrgSchCfgCfm(LrgSchCfgCfm func,Pst *pst,Buffer *mBuf);
35 /**************************************************************************
36  * @brief Task Initiation callback function. 
37  *
38  * @details
39  *
40  *     Function : duActvInit 
41  *    
42  *     Functionality:
43  *             This function is supplied as one of parameters during DU APP's 
44  *             task registration. SSI will invoke this function once, after
45  *             it creates and attaches this TAPA Task to a system task.
46  *     
47  * @param[in]  Ent entity, the entity ID of this task.     
48  * @param[in]  Inst inst, the instance ID of this task.
49  * @param[in]  Region region, the region ID registered for memory 
50  *              usage of this task.
51  * @param[in]  Reason reason.
52  * @return ROK     - success
53  *         RFAILED - failure
54  ***************************************************************************/
55 S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason)
56 {
57    uint8_t id;
58
59    duCb.init.procId  = SFndProcId();
60    duCb.init.ent     = entity;
61    duCb.init.inst    = inst;
62    duCb.init.region  = region;
63    duCb.init.reason  = reason;
64    duCb.init.cfgDone = FALSE;
65    duCb.init.pool    = DU_POOL;
66    duCb.init.acnt    = FALSE;
67    duCb.init.trc     = FALSE;
68    duCb.init.usta    = TRUE;
69    duCb.mem.region   = DFLT_REGION;
70    duCb.mem.pool     = DU_POOL;
71
72    duCb.f1Status     = FALSE;
73    duCb.e2Status     = FALSE;
74
75    for(id = 0; id < DU_MAX_CELLS; id ++)
76    {
77            duCb.cfgCellLst[id] = NULL;
78       duCb.actvCellLst[id] = NULL;
79    }
80
81    SSetProcId(DU_PROC);
82
83    return ROK;
84
85 }
86
87 /**************************************************************************
88  * @brief Task Activation callback function. 
89  *
90  * @details
91  *
92  *      Function : duActvTsk 
93  * 
94  *      Functionality:
95  *           Primitives invoked by DU APP's users/providers through
96  *           a loosely coupled interface arrive here by means of 
97  *           SSI's message handling. This API is registered with
98  *           SSI during the Task Registration of DU APP.
99  *     
100  * @param[in]  Pst     *pst, Post structure of the primitive.     
101  * @param[in]  Buffer *mBuf, Packed primitive parameters in the
102  *  buffer.
103  * @return ROK     - success
104  *         RFAILED - failure
105  *
106  ***************************************************************************/
107 S16 duActvTsk(Pst *pst, Buffer *mBuf)
108 {
109    S16 ret = ROK;
110
111    switch(pst->srcEnt)
112    {
113       case ENTDUAPP:
114          {
115             switch(pst->event)
116             {
117                case EVTCFG:
118                   {
119                      DU_LOG("\n****** Received initial configs at DU APP ******\n");
120                      duProcCfgComplete();
121                      SPutMsg(mBuf);
122                      break;
123                   }
124                default:
125                   {
126                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTDUAPP");
127                      SPutMsg(mBuf);
128                      ret = RFAILED;
129                   }
130             }
131
132             break;
133          }
134       case ENTKW:
135          {
136             switch(pst->event)
137             {
138                case LKW_EVT_CFG_CFM:
139                   {
140                      ret = cmUnpkLkwCfgCfm(duHdlRlcCfgComplete, pst, mBuf);
141                      break;
142                   }
143                case LKW_EVT_CNTRL_CFM:
144                   {
145                      ret = cmUnpkLkwCntrlCfm(duHdlRlcCntrlCfgComplete, pst, mBuf);
146                      break;
147                   }
148                case LKW_EVT_STA_IND:
149                   {
150                      break;
151                   }
152                case KWU_EVT_DAT_IND:
153                   {
154                      ret = cmUnpkKwuDatInd(duHdlRlcUlData, pst, mBuf);
155                      break;
156                   }
157                default:
158                   {
159                      DU_LOG("\nDU_APP : Invalid event %d received at duActvTsk from ENTKW", \
160                            pst->event);
161                      SPutMsg(mBuf);
162                      ret = RFAILED;
163                   }
164             }
165             break;
166          }
167       case ENTRG:
168          {
169             switch(pst->event)
170             {
171                //Config complete
172                case EVTCFG:
173                   {
174                      SPutMsg(mBuf);
175                      break;
176                   }
177                case EVTLRGCFGCFM:
178                   {
179                      ret = cmUnpkLrgCfgCfm(duHdlMacCfgComplete, pst, mBuf);
180                      break;
181                   }
182                case EVTLRGCNTRLCFM:
183                   {
184                      break;
185                   }
186                case EVTMACSCHGENCFGCFM:
187                   {
188                      ret = cmUnpkLrgSchCfgCfm(duHdlSchCfgComplete, pst, mBuf);
189                      break;
190                   }
191                case EVENT_MAC_CELL_CONFIG_CFM:
192                   {
193                      ret = unpackMacCellCfgCfm(duHandleMacCellCfgCfm, pst, mBuf);
194                      break;
195                   }
196                case EVENT_MAC_SLOT_IND:
197                   {
198                      ret = unpackMacSlotInd(duHandleSlotInd, pst, mBuf);
199                      break;
200                   }
201                default:
202                   {
203                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTRG");
204                      SPutMsg(mBuf);
205                      ret = RFAILED;
206                   }
207             }
208
209             break;
210          }
211       case ENTSCTP:
212          {
213             switch(pst->event)
214             {
215                case EVENT_CU_DATA:
216                {
217                   F1APMsgHdlr(mBuf);
218                   break;
219                }
220                case EVENT_SCTP_NTFY:
221                {
222                   ret = cmUnpkSctpNtfy(duSctpNtfyHdl, pst, mBuf);
223                   break;
224                }
225                case EVENT_RIC_DATA:
226                {
227                   E2APMsgHdlr(mBuf);
228                   break;
229                }
230                default:
231                {
232                   DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTSCTP");
233                   ret = RFAILED;
234                }
235
236             }
237             SPutMsg(mBuf);
238             break;
239          }
240       case ENTEGTP:
241          {
242             switch(pst->event)
243             {
244                case EVTCFGCFM:
245                {
246                   unpackEgtpCfgCfm(duHdlEgtpCfgComplete, mBuf);
247                   break;
248                }
249                case EVTSRVOPENCFM:
250                {
251                   unpackEgtpSrvOpenCfm(duHdlEgtpSrvOpenComplete, mBuf);
252                   break;
253                }
254                case EVTTNLMGMTCFM:
255                {
256                   unpackEgtpTnlMgmtCfm(duHdlEgtpTnlMgmtCfm, mBuf);
257                   break;
258                }
259                default:
260                {
261                   DU_LOG("\nDU_APP : Invalid event[%d] received at duActvTsk from ENTEGTP", pst->event);
262                   ret = RFAILED;
263                }
264             }
265             SPutMsg(mBuf);
266             break;
267          }
268       default:
269          {
270             DU_LOG("\nDU_APP : DU APP can not process message from Entity %d", pst->srcEnt);
271             SPutMsg(mBuf);
272             ret = RFAILED;
273          }
274
275    }
276    SExitTsk();
277    return ret;
278 }
279
280 /**********************************************************************
281          End of file
282 **********************************************************************/