E2AP changes Part2
[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    memset(duCb.cfgCellLst, '\0', DU_MAX_CELLS * sizeof(duCb.cfgCellLst));
74    memset(duCb.actvCellLst, '\0',DU_MAX_CELLS * sizeof(duCb.actvCellLst));
75
76    SSetProcId(DU_PROC);
77
78    return ROK;
79
80 }
81
82 /**************************************************************************
83  * @brief Task Activation callback function. 
84  *
85  * @details
86  *
87  *      Function : duActvTsk 
88  * 
89  *      Functionality:
90  *           Primitives invoked by DU APP's users/providers through
91  *           a loosely coupled interface arrive here by means of 
92  *           SSI's message handling. This API is registered with
93  *           SSI during the Task Registration of DU APP.
94  *     
95  * @param[in]  Pst     *pst, Post structure of the primitive.     
96  * @param[in]  Buffer *mBuf, Packed primitive parameters in the
97  *  buffer.
98  * @return ROK     - success
99  *         RFAILED - failure
100  *
101  ***************************************************************************/
102 S16 duActvTsk(Pst *pst, Buffer *mBuf)
103 {
104    S16 ret = ROK;
105
106    switch(pst->srcEnt)
107    {
108       case ENTDUAPP:
109          {
110             switch(pst->event)
111             {
112                case EVTCFG:
113                   {
114                      DU_LOG("\n****** Received initial configs at DU APP ******\n");
115                      duProcCfgComplete();
116                      SPutMsg(mBuf);
117                      break;
118                   }
119                default:
120                   {
121                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTDUAPP");
122                      SPutMsg(mBuf);
123                      ret = RFAILED;
124                   }
125             }
126
127             break;
128          }
129       case ENTKW:
130          {
131             switch(pst->event)
132             {
133                case LKW_EVT_CFG_CFM:
134                   {
135                      ret = cmUnpkLkwCfgCfm(duHdlRlcCfgComplete, pst, mBuf);
136                      break;
137                   }
138                case LKW_EVT_CNTRL_CFM:
139                   {
140                      ret = cmUnpkLkwCntrlCfm(duHdlRlcCntrlCfgComplete, pst, mBuf);
141                      break;
142                   }
143                case LKW_EVT_STA_IND:
144                   {
145                      break;
146                   }
147                case KWU_EVT_DAT_IND:
148                   {
149                      ret = cmUnpkKwuDatInd(duHdlRlcUlData, pst, mBuf);
150                      break;
151                   }
152                default:
153                   {
154                      DU_LOG("\nDU_APP : Invalid event %d received at duActvTsk from ENTKW", \
155                            pst->event);
156                      SPutMsg(mBuf);
157                      ret = RFAILED;
158                   }
159             }
160             break;
161          }
162       case ENTRG:
163          {
164             switch(pst->event)
165             {
166                //Config complete
167                case EVTCFG:
168                   {
169                      SPutMsg(mBuf);
170                      break;
171                   }
172                case EVTLRGCFGCFM:
173                   {
174                      ret = cmUnpkLrgCfgCfm(duHdlMacCfgComplete, pst, mBuf);
175                      break;
176                   }
177                case EVTLRGCNTRLCFM:
178                   {
179                      break;
180                   }
181                case EVTMACSCHGENCFGCFM:
182                   {
183                      ret = cmUnpkLrgSchCfgCfm(duHdlSchCfgComplete, pst, mBuf);
184                      break;
185                   }
186                case EVENT_MAC_CELL_CONFIG_CFM:
187                   {
188                      ret = unpackMacCellCfgCfm(duHandleMacCellCfgCfm, pst, mBuf);
189                      break;
190                   }
191                default:
192                   {
193                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTRG");
194                      SPutMsg(mBuf);
195                      ret = RFAILED;
196                   }
197             }
198
199             break;
200          }
201       case ENTSCTP:
202          {
203             switch(pst->event)
204             {
205                case EVENT_CU_DATA:
206                {
207                   F1APMsgHdlr(mBuf);
208                   break;
209                }
210                case EVENT_SCTP_NTFY:
211                {
212                   ret = cmUnpkSctpNtfy(duSctpNtfyHdl, pst, mBuf);
213                   break;
214                }
215                case EVENT_RIC_DATA:
216                {
217                   E2APMsgHdlr(mBuf);
218                   break;
219                }
220                default:
221                {
222                   DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTSCTP");
223                   ret = RFAILED;
224                }
225
226             }
227             SPutMsg(mBuf);
228             break;
229          }
230       case ENTEGTP:
231          {
232             switch(pst->event)
233             {
234                case EVTCFGCFM:
235                {
236                   cmUnpkEgtpCfgCfm(duHdlEgtpCfgComplete, mBuf);
237                   break;
238                }
239                case EVTSRVOPENCFM:
240                {
241                   cmUnpkEgtpSrvOpenCfm(duHdlEgtpSrvOpenComplete, mBuf);
242                   break;
243                }
244                case EVTTNLMGMTCFM:
245                {
246                   cmUnpkEgtpTnlMgmtCfm(duHdlEgtpTnlMgmtCfm, mBuf);
247                   break;
248                }
249                default:
250                {
251                   DU_LOG("\nDU_APP : Invalid event[%d] received at duActvTsk from ENTEGTP", pst->event);
252                   ret = RFAILED;
253                }
254             }
255             SPutMsg(mBuf);
256             break;
257          }
258       default:
259          {
260             DU_LOG("\nDU_APP : DU APP can not process message from Entity %d", pst->srcEnt);
261             SPutMsg(mBuf);
262             ret = RFAILED;
263          }
264
265    }
266    SExitTsk();
267    return ret;
268 }
269
270 /**********************************************************************
271          End of file
272 **********************************************************************/