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