44a83ccfc3e9c796ee186678156e5e0408e2488e
[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 cell management */
20
21 #include "du_sctp.h"
22 #include "f1ap_msg_hdl.h"
23
24 extern S16 cmUnpkLkwCfgCfm(LkwCfgCfm func,Pst *pst, Buffer *mBuf);
25 extern S16 cmUnpkLkwCntrlCfm(LkwCntrlCfm func,Pst *pst, Buffer *mBuf);
26 extern S16 cmUnpkLrgCfgCfm(LrgCfgCfm func,Pst *pst, Buffer *mBuf);
27
28 /**************************************************************************
29  * @brief Task Initiation callback function. 
30  *
31  * @details
32  *
33  *     Function : duActvInit 
34  *    
35  *     Functionality:
36  *             This function is supplied as one of parameters during DU APP's 
37  *             task registration. SSI will invoke this function once, after
38  *             it creates and attaches this TAPA Task to a system task.
39  *     
40  * @param[in]  Ent entity, the entity ID of this task.     
41  * @param[in]  Inst inst, the instance ID of this task.
42  * @param[in]  Region region, the region ID registered for memory 
43  *              usage of this task.
44  * @param[in]  Reason reason.
45  * @return ROK     - success
46  *         RFAILED - failure
47  ***************************************************************************/
48 S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason)
49 {
50    duCb.init.procId  = SFndProcId();
51    duCb.init.ent     = entity;
52    duCb.init.inst    = inst;
53    duCb.init.region  = region;
54    duCb.init.reason  = reason;
55    duCb.init.cfgDone = FALSE;
56    duCb.init.pool    = DU_POOL;
57    duCb.init.acnt    = FALSE;
58    duCb.init.trc     = FALSE;
59    duCb.init.usta    = TRUE;
60    duCb.mem.region   = DFLT_REGION;
61    duCb.mem.pool     = DU_POOL;
62
63    duCb.sctpStatus   = FALSE;
64    duCb.f1Status     = FALSE;
65    duCb.duStatus     = FALSE;
66
67    SSetProcId(DU_PROC);
68
69    return ROK;
70
71 }
72
73 /**************************************************************************
74  * @brief Task Activation callback function. 
75  *
76  * @details
77  *
78  *      Function : duActvTsk 
79  * 
80  *      Functionality:
81  *           Primitives invoked by DU APP's users/providers through
82  *           a loosely coupled interface arrive here by means of 
83  *           SSI's message handling. This API is registered with
84  *           SSI during the Task Registration of DU APP.
85  *     
86  * @param[in]  Pst     *pst, Post structure of the primitive.     
87  * @param[in]  Buffer *mBuf, Packed primitive parameters in the
88  *  buffer.
89  * @return ROK     - success
90  *         RFAILED - failure
91  *
92  ***************************************************************************/
93 S16 duActvTsk(Pst *pst, Buffer *mBuf)
94 {
95    S16 ret = ROK;
96
97    switch(pst->srcEnt)
98    {
99       case ENTDUAPP:
100          {
101             switch(pst->event)
102             {
103                case EVTCFG:
104                   {
105                      duSendRlcUlCfg();
106                      SPutMsg(mBuf);
107                      break;
108                   }
109                default:
110                   {
111                      printf("\nInvalid event received at duActvTsk from ENTDUAPP");
112                      SPutMsg(mBuf);
113                      ret = RFAILED;
114                   }
115             }
116
117             break;
118          }
119       case ENTKW:
120          {
121             switch(pst->event)
122             {
123                case LKW_EVT_CFG_CFM:
124                   {
125                      ret = cmUnpkLkwCfgCfm(duHdlRlcCfgComplete, pst, mBuf);
126                      break;
127                   }
128                case LKW_EVT_CNTRL_CFM:
129                   {
130                      ret = cmUnpkLkwCntrlCfm(duHdlRlcCntrlCfgComplete, pst, mBuf);
131                      break;
132                   }
133                case LKW_EVT_STA_IND:
134                   {
135                      break;
136                   }
137                default:
138                   {
139                      printf("\nInvalid event %d received at duActvTsk from ENTKW", \
140                            pst->event);
141                      SPutMsg(mBuf);
142                      ret = RFAILED;
143                   }
144             }
145             break;
146          }
147       case ENTRG:
148          {
149             switch(pst->event)
150             {
151                //Config complete
152                case EVTCFG:
153                   {
154                      SPutMsg(mBuf);
155                      break;
156                   }
157                case EVTLRGCFGCFM:
158                   {
159                      ret = cmUnpkLrgCfgCfm(duHdlMacCfgComplete, pst, mBuf);
160                      break;
161                   }
162                case EVTLRGCNTRLCFM:
163                   {
164                      break;
165                   }
166                default:
167                   {
168                      printf("\nInvalid event received at duActvTsk from ENTRG");
169                      SPutMsg(mBuf);
170                      ret = RFAILED;
171                   }
172             }
173
174             break;
175          }
176       case ENTSCTP:
177          {
178             switch(pst->event)
179             {
180                case EVTSCTPDATA:
181                {
182                   F1InmsgHdlr(mBuf);
183                   break;
184                }
185                case EVTSCTPNTFY:
186                   {
187                      ret = cmUnpkSctpNtfy(duSctpNtfyHdl, pst, mBuf);
188                      break;
189                   }
190                default:
191                   {
192                      printf("\nInvalid event received at duActvTsk from ENTRG");
193                      ret = RFAILED;
194                   }
195
196             }
197             SPutMsg(mBuf);
198             break;
199          }
200       default:
201          {
202             printf("\n DU APP can not process message from Entity %d", pst->srcEnt);
203             SPutMsg(mBuf);
204             ret = RFAILED;
205          }
206
207    }
208    SExitTsk();
209    return ret;
210 }
211
212 /**********************************************************************
213          End of file
214 **********************************************************************/