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