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