F1-U Data path changes
[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
29 #include "kwu.x"
30
31 extern S16 cmUnpkLkwCfgCfm(LkwCfgCfm func,Pst *pst, Buffer *mBuf);
32 extern S16 cmUnpkLkwCntrlCfm(LkwCntrlCfm func,Pst *pst, Buffer *mBuf);
33 extern S16 cmUnpkLrgCfgCfm(LrgCfgCfm func,Pst *pst, Buffer *mBuf);
34
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    duCb.init.procId  = SFndProcId();
58    duCb.init.ent     = entity;
59    duCb.init.inst    = inst;
60    duCb.init.region  = region;
61    duCb.init.reason  = reason;
62    duCb.init.cfgDone = FALSE;
63    duCb.init.pool    = DU_POOL;
64    duCb.init.acnt    = FALSE;
65    duCb.init.trc     = FALSE;
66    duCb.init.usta    = TRUE;
67    duCb.mem.region   = DFLT_REGION;
68    duCb.mem.pool     = DU_POOL;
69
70    duCb.f1Status     = FALSE;
71    duCb.e2Status     = FALSE;
72
73    if(ROK != cmHashListInit(&(duCb.cellLst), 
74             (U16) DU_MAX_CELLS,
75             (U16) 0,
76             (Bool) FALSE, 
77             (U16) CM_HASH_KEYTYPE_CONID,
78             0,   
79             0))
80    {
81       DU_LOG("\nDU_APP : cellLst Initialization Failed");
82    }
83
84    if(ROK != cmHashListInit(&(duCb.actvCellLst), 
85             (U16) DU_MAX_CELLS,
86             (U16) 0,
87             (Bool) FALSE, 
88             (U16) CM_HASH_KEYTYPE_CONID,
89             0,   
90             0))
91    {
92       DU_LOG("\nDU_APP : ActvCellLst Initialization Failed");
93    }
94
95    SSetProcId(DU_PROC);
96
97    return ROK;
98
99 }
100
101 /**************************************************************************
102  * @brief Task Activation callback function. 
103  *
104  * @details
105  *
106  *      Function : duActvTsk 
107  * 
108  *      Functionality:
109  *           Primitives invoked by DU APP's users/providers through
110  *           a loosely coupled interface arrive here by means of 
111  *           SSI's message handling. This API is registered with
112  *           SSI during the Task Registration of DU APP.
113  *     
114  * @param[in]  Pst     *pst, Post structure of the primitive.     
115  * @param[in]  Buffer *mBuf, Packed primitive parameters in the
116  *  buffer.
117  * @return ROK     - success
118  *         RFAILED - failure
119  *
120  ***************************************************************************/
121 S16 duActvTsk(Pst *pst, Buffer *mBuf)
122 {
123    S16 ret = ROK;
124
125    switch(pst->srcEnt)
126    {
127       case ENTDUAPP:
128          {
129             switch(pst->event)
130             {
131                case EVTCFG:
132                   {
133                      DU_LOG("\n****** Received initial configs at DU APP ******\n");
134                      duProcCfgComplete();
135                      SPutMsg(mBuf);
136                      break;
137                   }
138                default:
139                   {
140                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTDUAPP");
141                      SPutMsg(mBuf);
142                      ret = RFAILED;
143                   }
144             }
145
146             break;
147          }
148       case ENTKW:
149          {
150             switch(pst->event)
151             {
152                case LKW_EVT_CFG_CFM:
153                   {
154                      ret = cmUnpkLkwCfgCfm(duHdlRlcCfgComplete, pst, mBuf);
155                      break;
156                   }
157                case LKW_EVT_CNTRL_CFM:
158                   {
159                      ret = cmUnpkLkwCntrlCfm(duHdlRlcCntrlCfgComplete, pst, mBuf);
160                      break;
161                   }
162                case LKW_EVT_STA_IND:
163                   {
164                      break;
165                   }
166                case KWU_EVT_DAT_IND:
167                   {
168                      ret = cmUnpkKwuDatInd(duHdlRlcUlData, pst, mBuf);
169                      break;
170                   }
171                default:
172                   {
173                      DU_LOG("\nDU_APP : Invalid event %d received at duActvTsk from ENTKW", \
174                            pst->event);
175                      SPutMsg(mBuf);
176                      ret = RFAILED;
177                   }
178             }
179             break;
180          }
181       case ENTRG:
182          {
183             switch(pst->event)
184             {
185                //Config complete
186                case EVTCFG:
187                   {
188                      SPutMsg(mBuf);
189                      break;
190                   }
191                case EVTLRGCFGCFM:
192                   {
193                      ret = cmUnpkLrgCfgCfm(duHdlMacCfgComplete, pst, mBuf);
194                      break;
195                   }
196                case EVTLRGCNTRLCFM:
197                   {
198                      break;
199                   }
200                case EVTMACSCHGENCFGCFM:
201                   {
202                      ret = cmUnpkLrgSchCfgCfm(duHdlSchCfgComplete, pst, mBuf);
203                      break;
204                   }
205                case EVENT_MAC_CELL_CONFIG_CFM:
206                   {
207                      ret = unpackMacCellCfgCfm(duHandleMacCellCfgCfm, pst, mBuf);
208                      break;
209                   }
210                default:
211                   {
212                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTRG");
213                      SPutMsg(mBuf);
214                      ret = RFAILED;
215                   }
216             }
217
218             break;
219          }
220       case ENTSCTP:
221          {
222             switch(pst->event)
223             {
224                case EVTSCTPDATA:
225                {
226                   F1APMsgHdlr(mBuf);
227                   break;
228                }
229                case EVTSCTPNTFY:
230                {
231                   ret = cmUnpkSctpNtfy(duSctpNtfyHdl, pst, mBuf);
232                   break;
233                }
234                case EVTRICDATA:
235                {
236                   E2APMsgHdlr(mBuf);
237                   break;
238                }
239
240                default:
241                {
242                   DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTSCTP");
243                   ret = RFAILED;
244                }
245
246             }
247             SPutMsg(mBuf);
248             break;
249          }
250       case ENTEGTP:
251          {
252             switch(pst->event)
253             {
254                case EVTCFGCFM:
255                {
256                   cmUnpkEgtpCfgCfm(duHdlEgtpCfgComplete, mBuf);
257                   break;
258                }
259                case EVTSRVOPENCFM:
260                {
261                   cmUnpkEgtpSrvOpenCfm(duHdlEgtpSrvOpenComplete, mBuf);
262                   break;
263                }
264                case EVTTNLMGMTCFM:
265                {
266                   cmUnpkEgtpTnlMgmtCfm(duHdlEgtpTnlMgmtCfm, mBuf);
267                   break;
268                }
269                default:
270                {
271                   DU_LOG("\nDU_APP : Invalid event[%d] received at duActvTsk from ENTEGTP", pst->event);
272                   ret = RFAILED;
273                }
274             }
275             SPutMsg(mBuf);
276             break;
277          }
278       default:
279          {
280             DU_LOG("\nDU_APP : DU APP can not process message from Entity %d", pst->srcEnt);
281             SPutMsg(mBuf);
282             ret = RFAILED;
283          }
284
285    }
286    SExitTsk();
287    return ret;
288 }
289
290 /**********************************************************************
291          End of file
292 **********************************************************************/