fce7500e907afeadc3183b7510ce56bd8f8b3356
[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 "lsctp.h"
24 #include "legtp.h"
25 #include "lkw.h"
26 #include "kwu.h"
27 #include "lrg.x"
28 #include "lkw.x"
29 #include "kwu.x"
30 #include "du_app_mac_inf.h"
31 #include "du_app_rlc_inf.h"
32 #include "du_cfg.h"
33 #include "du_mgr.h"
34 #include "E2AP-PDU.h"
35 #include "du_sctp.h"
36 #include "F1AP-PDU.h"
37 #include "du_f1ap_msg_hdl.h"
38 #include "du_e2ap_msg_hdl.h"
39 #include "du_app_mac_inf.h"
40 #include "du_ue_mgr.h"
41 #include "du_utils.h"
42
43 extern uint8_t unpackRlcConfigCfm(RlcConfigCfm func,Pst *pst, Buffer *mBuf);
44 extern uint8_t cmUnpkLkwCntrlCfm(LkwCntrlCfm func,Pst *pst, Buffer *mBuf);
45 extern uint8_t cmUnpkLrgCfgCfm(LrgCfgCfm func,Pst *pst, Buffer *mBuf);
46 extern uint8_t cmUnpkKwuDatInd(KwuDatInd func,Pst *pst, Buffer *mBuf);
47 extern uint8_t cmUnpkLrgSchCfgCfm(LrgSchCfgCfm func,Pst *pst,Buffer *mBuf);
48 /**************************************************************************
49  * @brief Task Initiation callback function. 
50  *
51  * @details
52  *
53  *     Function : duActvInit 
54  *    
55  *     Functionality:
56  *             This function is supplied as one of parameters during DU APP's 
57  *             task registration. SSI will invoke this function once, after
58  *             it creates and attaches this TAPA Task to a system task.
59  *     
60  * @param[in]  Ent entity, the entity ID of this task.     
61  * @param[in]  Inst inst, the instance ID of this task.
62  * @param[in]  Region region, the region ID registered for memory 
63  *              usage of this task.
64  * @param[in]  Reason reason.
65  * @return ROK     - success
66  *         RFAILED - failure
67  ***************************************************************************/
68 uint8_t duActvInit(Ent entity, Inst inst, Region region, Reason reason)
69 {
70    uint8_t id;
71
72    memset(&duCb, 0, sizeof(DuCb));
73
74    duCb.init.procId  = SFndProcId();
75    duCb.init.ent     = entity;
76    duCb.init.inst    = inst;
77    duCb.init.region  = region;
78    duCb.init.reason  = reason;
79    duCb.init.cfgDone = FALSE;
80    duCb.init.pool    = DU_POOL;
81    duCb.init.acnt    = FALSE;
82    duCb.init.trc     = FALSE;
83    duCb.init.usta    = TRUE;
84    duCb.mem.region   = DFLT_REGION;
85    duCb.mem.pool     = DU_POOL;
86
87    duCb.f1Status     = FALSE;
88    duCb.e2Status     = FALSE;
89
90    for(id = 0; id < MAX_NUM_CELL; id ++)
91    {
92       duCb.cfgCellLst[id] = NULL;
93       duCb.actvCellLst[id] = NULL;
94    }
95    duCb.numUe = 0;
96    memset(duCb.ueCcchCtxt, 0, MAX_NUM_UE * sizeof(UeCcchCtxt));
97    duCb.numCfgCells  = 0;
98    duCb.numActvCells = 0;
99
100    ODU_SET_PROC_ID(DU_PROC);
101
102    return ROK;
103
104 }
105
106 /**************************************************************************
107  * @brief Task Activation callback function. 
108  *
109  * @details
110  *
111  *      Function : duActvTsk 
112  * 
113  *      Functionality:
114  *           Primitives invoked by DU APP's users/providers through
115  *           a loosely coupled interface arrive here by means of 
116  *           SSI's message handling. This API is registered with
117  *           SSI during the Task Registration of DU APP.
118  *     
119  * @param[in]  Pst     *pst, Post structure of the primitive.     
120  * @param[in]  Buffer *mBuf, Packed primitive parameters in the
121  *  buffer.
122  * @return ROK     - success
123  *         RFAILED - failure
124  *
125  ***************************************************************************/
126 uint8_t duActvTsk(Pst *pst, Buffer *mBuf)
127 {
128    uint8_t ret = ROK;
129
130    switch(pst->srcEnt)
131    {
132       case ENTDUAPP:
133          {
134             switch(pst->event)
135             {
136                case EVTCFG:
137                   {
138                      DU_LOG("\n****** Received initial configs at DU APP ******\n");
139                      duProcCfgComplete();
140                      ODU_PUT_MSG_BUF(mBuf);
141                      break;
142                   }
143                default:
144                   {
145                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTDUAPP");
146                      ODU_PUT_MSG_BUF(mBuf);
147                      ret = RFAILED;
148                   }
149             }
150
151             break;
152          }
153       case ENTRLC:
154          {
155             switch(pst->event)
156             {
157                case LKW_EVT_CFG_CFM:
158                   {
159                      ret = unpackRlcConfigCfm(DuHdlRlcCfgComplete, pst, mBuf);
160                      break;
161                   }
162                case LKW_EVT_CNTRL_CFM:
163                   {
164                      ret = cmUnpkLkwCntrlCfm(duHdlRlcCntrlCfgComplete, pst, mBuf);
165                      break;
166                   }
167                case LKW_EVT_STA_IND:
168                   {
169                      break;
170                   }
171                case KWU_EVT_DAT_IND:
172                   {
173                      ret = cmUnpkKwuDatInd(duHdlRlcUlData, pst, mBuf);
174                      break;
175                   }
176                case EVENT_RLC_UL_UE_CREATE_RSP:
177                   {
178                      ret = unpackRlcUlUeCreateRsp(DuProcRlcUlUeCreateRsp, pst, mBuf);
179                      break;
180                   }
181                case EVENT_UL_RRC_MSG_TRANS_TO_DU:
182                   {
183                      ret = unpackRlcUlRrcMsgToDu(DuProcRlcUlRrcMsgTrans, pst, mBuf);
184                      break;
185                   }
186                case EVENT_RRC_DELIVERY_MSG_TRANS_TO_DU:
187                   {
188                      ret = unpackRrcDeliveryReportToDu(DuProcRlcRrcDeliveryReport, pst, mBuf);
189                      break;
190                   }
191                default:
192                   {
193                      DU_LOG("\nDU_APP : Invalid event %d received at duActvTsk from ENTRLC", \
194                            pst->event);
195                      ODU_PUT_MSG_BUF(mBuf);
196                      ret = RFAILED;
197                   }
198             }
199             break;
200          }
201       case ENTMAC:
202          {
203             switch(pst->event)
204             {
205                //Config complete
206                case EVTCFG:
207                   {
208                      ODU_PUT_MSG_BUF(mBuf);
209                      break;
210                   }
211                case EVTLRGCFGCFM:
212                   {
213                      ret = cmUnpkLrgCfgCfm(duHdlMacCfgComplete, pst, mBuf);
214                      break;
215                   }
216                case EVTLRGCNTRLCFM:
217                   {
218                      break;
219                   }
220                case EVTMACSCHGENCFGCFM:
221                   {
222                      ret = cmUnpkLrgSchCfgCfm(duHdlSchCfgComplete, pst, mBuf);
223                      break;
224                   }
225                case EVENT_MAC_CELL_CONFIG_CFM:
226                   {
227                      ret = unpackMacCellCfgCfm(duHandleMacCellCfgCfm, pst, mBuf);
228                      break;
229                   }
230                case EVENT_MAC_SLOT_IND:
231                   {
232                      ret = unpackMacSlotInd(duHandleSlotInd, pst, mBuf);
233                      break;
234                   }
235                case EVENT_MAC_STOP_IND:
236                   {
237                      ret = unpackMacStopInd(duHandleStopInd, pst, mBuf);
238                      break;
239                   }
240                case EVENT_MAC_UL_CCCH_IND:
241                   {
242                      ret = unpackMacUlCcchInd(duHandleUlCcchInd, pst, mBuf);
243                      break;
244                   }
245                case EVENT_MAC_UE_CREATE_RSP:
246                   {
247                      ret = unpackDuMacUeCreateRsp(DuHandleMacUeCreateRsp, pst, mBuf); 
248                      break;
249                   }
250
251                default:
252                   {
253                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTMAC");
254                      ODU_PUT_MSG_BUF(mBuf);
255                      ret = RFAILED;
256                   }
257             }
258
259             break;
260          }
261       case ENTSCTP:
262          {
263             switch(pst->event)
264             {
265                case EVENT_CU_DATA:
266                   {
267                      F1APMsgHdlr(mBuf);
268                      break;
269                   }
270                case EVENT_SCTP_NTFY:
271                   {
272                      ret = cmUnpkSctpNtfy(duSctpNtfyHdl, pst, mBuf);
273                      break;
274                   }
275                case EVENT_RIC_DATA:
276                   {
277                      E2APMsgHdlr(mBuf);
278                      break;
279                   }
280                default:
281                   {
282                      DU_LOG("\nDU_APP : Invalid event received at duActvTsk from ENTSCTP");
283                      ret = RFAILED;
284                   }
285
286             }
287             ODU_PUT_MSG_BUF(mBuf);
288             break;
289          }
290       case ENTEGTP:
291          {
292             switch(pst->event)
293             {
294                case EVTCFGCFM:
295                   {
296                      unpackEgtpCfgCfm(duHdlEgtpCfgComplete, mBuf);
297                      break;
298                   }
299                case EVTSRVOPENCFM:
300                   {
301                      unpackEgtpSrvOpenCfm(duHdlEgtpSrvOpenComplete, mBuf);
302                      break;
303                   }
304                case EVTTNLMGMTCFM:
305                   {
306                      unpackEgtpTnlMgmtCfm(duHdlEgtpTnlMgmtCfm, mBuf);
307                      break;
308                   }
309                default:
310                   {
311                      DU_LOG("\nDU_APP : Invalid event[%d] received at duActvTsk from ENTEGTP", pst->event);
312                      ret = RFAILED;
313                   }
314             }
315             ODU_PUT_MSG_BUF(mBuf);
316             break;
317          }
318       default:
319          {
320             DU_LOG("\nDU_APP : DU APP can not process message from Entity %d", pst->srcEnt);
321             ODU_PUT_MSG_BUF(mBuf);
322             ret = RFAILED;
323          }
324
325    }
326    ODU_EXIT_TASK();
327    return ret;
328 }
329
330 /**********************************************************************
331   End of file
332  **********************************************************************/