JIRA ID ODUHIGH193: Allocation and deallocation of MaceCellCfg sharable buffer
[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    duCb.numCfgCells  = 0;
92    duCb.numActvCells = 0;
93    SSetProcId(DU_PROC);
94
95    return ROK;
96
97 }
98
99 /**************************************************************************
100  * @brief Task Activation callback function. 
101  *
102  * @details
103  *
104  *      Function : duActvTsk 
105  * 
106  *      Functionality:
107  *           Primitives invoked by DU APP's users/providers through
108  *           a loosely coupled interface arrive here by means of 
109  *           SSI's message handling. This API is registered with
110  *           SSI during the Task Registration of DU APP.
111  *     
112  * @param[in]  Pst     *pst, Post structure of the primitive.     
113  * @param[in]  Buffer *mBuf, Packed primitive parameters in the
114  *  buffer.
115  * @return ROK     - success
116  *         RFAILED - failure
117  *
118  ***************************************************************************/
119 S16 duActvTsk(Pst *pst, Buffer *mBuf)
120 {
121    S16 ret = ROK;
122
123    switch(pst->srcEnt)
124    {
125       case ENTDUAPP:
126          {
127             switch(pst->event)
128             {
129                case EVTCFG:
130                   {
131                      DU_LOG("\n****** Received initial configs at DU APP ******\n");
132                      duProcCfgComplete();
133                      SPutMsg(mBuf);
134                      break;
135                   }
136                default:
137                   {
138                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTDUAPP");
139                      SPutMsg(mBuf);
140                      ret = RFAILED;
141                   }
142             }
143
144             break;
145          }
146       case ENTKW:
147          {
148             switch(pst->event)
149             {
150                case LKW_EVT_CFG_CFM:
151                   {
152                      ret = cmUnpkLkwCfgCfm(duHdlRlcCfgComplete, pst, mBuf);
153                      break;
154                   }
155                case LKW_EVT_CNTRL_CFM:
156                   {
157                      ret = cmUnpkLkwCntrlCfm(duHdlRlcCntrlCfgComplete, pst, mBuf);
158                      break;
159                   }
160                case LKW_EVT_STA_IND:
161                   {
162                      break;
163                   }
164                case KWU_EVT_DAT_IND:
165                   {
166                      ret = cmUnpkKwuDatInd(duHdlRlcUlData, pst, mBuf);
167                      break;
168                   }
169                default:
170                   {
171                      DU_LOG("\nDU_APP : Invalid event %d received at duActvTsk from ENTKW", \
172                            pst->event);
173                      SPutMsg(mBuf);
174                      ret = RFAILED;
175                   }
176             }
177             break;
178          }
179       case ENTRG:
180          {
181             switch(pst->event)
182             {
183                //Config complete
184                case EVTCFG:
185                   {
186                      SPutMsg(mBuf);
187                      break;
188                   }
189                case EVTLRGCFGCFM:
190                   {
191                      ret = cmUnpkLrgCfgCfm(duHdlMacCfgComplete, pst, mBuf);
192                      break;
193                   }
194                case EVTLRGCNTRLCFM:
195                   {
196                      break;
197                   }
198                case EVTMACSCHGENCFGCFM:
199                   {
200                      ret = cmUnpkLrgSchCfgCfm(duHdlSchCfgComplete, pst, mBuf);
201                      break;
202                   }
203                case EVENT_MAC_CELL_CONFIG_CFM:
204                   {
205                      ret = unpackMacCellCfgCfm(duHandleMacCellCfgCfm, pst, mBuf);
206                      break;
207                   }
208                case EVENT_MAC_SLOT_IND:
209                   {
210                      ret = unpackMacSlotInd(duHandleSlotInd, pst, mBuf);
211                      break;
212                   }
213                case EVENT_MAC_STOP_IND:
214                   {
215                      ret = unpackMacStopInd(duHandleStopInd, pst, mBuf);
216                      break;
217                   }
218                case EVENT_MAC_UL_CCCH_IND:
219                   {
220                      ret = unpackMacUlCcchInd(duHandleUlCcchInd, pst, mBuf);
221                      break;
222                   }
223                case EVENT_MAC_UE_CREATE_RSP:
224                   {
225                      ret = unpackDuMacUeCreateRsp(duHandleMacUeCreateRsp, pst, mBuf); 
226                   }
227
228                default:
229                   {
230                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTRG");
231                      SPutMsg(mBuf);
232                      ret = RFAILED;
233                   }
234             }
235
236             break;
237          }
238       case ENTSCTP:
239          {
240             switch(pst->event)
241             {
242                case EVENT_CU_DATA:
243                   {
244                      F1APMsgHdlr(mBuf);
245                      break;
246                   }
247                case EVENT_SCTP_NTFY:
248                   {
249                      ret = cmUnpkSctpNtfy(duSctpNtfyHdl, pst, mBuf);
250                      break;
251                   }
252                case EVENT_RIC_DATA:
253                   {
254                      E2APMsgHdlr(mBuf);
255                      break;
256                   }
257                default:
258                   {
259                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTSCTP");
260                      ret = RFAILED;
261                   }
262
263             }
264             SPutMsg(mBuf);
265             break;
266          }
267       case ENTEGTP:
268          {
269             switch(pst->event)
270             {
271                case EVTCFGCFM:
272                   {
273                      unpackEgtpCfgCfm(duHdlEgtpCfgComplete, mBuf);
274                      break;
275                   }
276                case EVTSRVOPENCFM:
277                   {
278                      unpackEgtpSrvOpenCfm(duHdlEgtpSrvOpenComplete, mBuf);
279                      break;
280                   }
281                case EVTTNLMGMTCFM:
282                   {
283                      unpackEgtpTnlMgmtCfm(duHdlEgtpTnlMgmtCfm, mBuf);
284                      break;
285                   }
286                default:
287                   {
288                      DU_LOG("\nDU_APP : Invalid event[%d] received at duActvTsk from ENTEGTP", pst->event);
289                      ret = RFAILED;
290                   }
291             }
292             SPutMsg(mBuf);
293             break;
294          }
295       default:
296          {
297             DU_LOG("\nDU_APP : DU APP can not process message from Entity %d", pst->srcEnt);
298             SPutMsg(mBuf);
299             ret = RFAILED;
300          }
301
302    }
303    SExitTsk();
304    return ret;
305 }
306
307 /**********************************************************************
308   End of file
309  **********************************************************************/