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