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