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