f5723e2de8476e45008cdf74cbb3ae6e3e5e208e
[o-du/l2.git] / src / 5gnrsch / sch_msg_router.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 /************************************************************************
20  
21      Name:     NR-SCH layer
22   
23      Type:     C source file
24   
25      Desc:     C source code SSI Interface Implementation
26   
27      File:     sch_msg_router.c
28   
29 **********************************************************************/
30
31 /** @file sch_msg_router.c
32 @brief This file contains the implementation of callback functions 
33 registered with SSI during the LTE MAC Task initialization.
34 */
35 /* header include files -- defines (.h) */
36 #include "common_def.h"
37 #include "tfu.h"           /* RGU defines */
38 #include "lrg.h"           /* layer management defines for LTE-MAC */
39 #include "rgr.h"           /* layer management defines for LTE-MAC */
40 #include "rgm.h"           /* layer management defines for LTE-MAC */
41 #include "rg_env.h"        /* customisable defines and macros for LTE-MAC */
42 #include "rg_sch_err.h"        /* defines and macros for Scheduler */
43 #include "rg_sch_inf.h"        /* defines and macros for Scheduler */
44 #include "rg_sch.h"        /* defines and macros for Scheduler */
45
46
47 /* header/extern include files (.x) */
48 #include "tfu.x"           /* RGU types */
49 #include "lrg.x"           /* layer management typedefs for MAC */
50 #include "rgr.x"           /* layer management typedefs for MAC */
51 #include "rgm.x"           /* layer management typedefs for MAC */
52 #include "rg_sch_inf.x"        /* typedefs for Scheduler */
53 #include "rg_sch.x"        /* typedefs for Scheduler */
54 #include "mac_sch_interface.h"
55
56 /*
57 * @brief
58 *
59 * Function:
60 *   name : callFlowSchActvTsk 
61 *
62 *  @b Description:
63 *  Function used to print values of src, dest, message
64 *  received at the layer
65 *
66 *  @param[in] pst   - Pst Structure
67 *
68 *  @return void
69 */
70
71 void callFlowSchActvTsk(Pst *pst)    
72 {
73    char sourceTask[50];
74    char destTask[50]="ENTSCH";
75    char message[100];
76
77    switch(pst->srcEnt)
78    {
79       case ENTMAC: /* When MAC sends a msg to Scheduler instance */
80          {
81             strcpy(sourceTask,"ENTMAC");
82             switch(pst->event)
83             {
84 #ifdef LCSCH
85                case EVTINFDEDBOUPDTREQ:
86                   strcpy(message,"EVTINFDEDBOUPDTREQ");
87                   break;
88                case EVTINFCMNBOUPDTREQ:
89                   strcpy(message,"EVTINFCMNBOUPDTREQ");
90                   break;   
91                case EVTINFSFRECPIND:
92                   strcpy(message,"EVTINFSFRECPIND");
93                   break;
94                   /*Fix: start: Inform UE delete to scheduler*/
95                case EVTINFUEDELIND:
96                   strcpy(message,"EVTINFUEDELIND");
97                   break;
98                   /*Fix: end: Inform UE delete to scheduler*/
99 #ifdef LTE_L2_MEAS
100                case EVTINFL2MEASCFM:
101                   strcpy(message,"EVTINFL2MEASCFM");
102                   break;
103                case EVTINFL2MEASSTOPCFM:
104                   strcpy(message,"EVTINFL2MEASSTOPCFM");
105                   break;
106 #endif
107 #endif            
108                case EVENT_SLOT_IND_TO_SCH:
109                   strcpy(message,"EVENT_SLOT_IND_TO_SCH");
110                   break;
111                default:
112                   strcpy(message,"Invalid Event");
113                   break;
114             }
115             break;
116          }
117       default:
118          strcpy(sourceTask,"Invalid Source Entity Id");
119          break;
120    }
121    DU_LOG("\nCall Flow: %s -> %s : %s\n", sourceTask, destTask, message);
122 }
123
124 /**
125  * @brief Task Activation callback function. 
126  *
127  * @details
128  *
129  *     Function : schActvTsk
130  *     
131  *     Primitives invoked by MAC's users/providers through
132  *     a loosely coupled interface arrive here by means of 
133  *     SSI's message handling. This API is registered with
134  *     SSI during the Task Registration of MAC.
135  *     
136  *  @param[in]  Pst     *pst, post structure of the Primitive.     
137  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
138  *  @param[in]  Reason reason.
139  *  @return  S16
140  *      -# ROK
141  **/
142 S16 schActvTsk
143 (
144 Pst     *pst,                       /* post structure       */
145 Buffer  *mBuf                       /* message buffer       */
146 )
147 {
148
149 #ifdef CALL_FLOW_DEBUG_LOG
150    callFlowSchActvTsk(pst);
151 #endif
152
153    switch(pst->srcEnt)
154    {
155       /* The originator of this message is the stack manager,
156        * unpack and go to the respective primitive processing function */
157       case ENTSM:
158          switch(pst->event)
159          {
160 #ifdef LCRGMILRG
161             case EVTMACSCHGENCFGREQ:
162                /* Process a config. request */
163                cmUnpkLrgSchCfgReq(SchProcGenCfgReq, pst, mBuf);
164                break;
165             case EVTLRGSCHCNTRLREQ:
166                /* Process a control request */
167                cmUnpkLrgSchCntrlReq(RgMiLrgSchCntrlReq, pst, mBuf);
168                break;
169             case EVTLRGSCHSTAIND:
170                /* Process a control request */
171                cmUnpkLrgSchStaInd(RgMiLrgSchStaInd, pst, mBuf);
172                break;
173 #ifdef LTE_L2_MEAS
174             case EVTLRGSCHL2MEASREQ:
175                /* Process L2 Measurement request */
176                cmUnpkLrgSchL2MeasReq(RgMiLrgSchL2MeasReq, pst, mBuf);
177                break;
178             case EVTLRGSCHL2MEASSTOPREQ:
179                /* Process L2 Measurement Stop request */
180                cmUnpkLrgSchL2MeasStopReq(RgMiLrgSchL2MeasStopReq, pst, mBuf);
181                break;
182             case EVTLRGSCHL2MEASSENDREQ:
183                /* Process L2 Measurement Send  request */
184                cmUnpkLrgSchL2MeasSendReq(RgMiLrgSchL2MeasSendReq, pst, mBuf);
185                break;
186 #endif
187 #endif /* LCRGMILRG */
188             default:
189                RGSCH_FREE_MSG(mBuf);
190                break;
191          }
192          break;
193      case ENTNX:
194          switch(pst->event)
195          {
196 #ifdef LCRGUIRGR
197             case EVTRGRBNDREQ:
198                cmUnpkRgrBndReq(RgUiRgrBndReq, pst, mBuf);
199                break;
200             case EVTRGRUBNDREQ:
201                cmUnpkRgrUbndReq(RgUiRgrUbndReq, pst, mBuf);
202                break;
203 #ifdef RGR_SI_SCH
204             case EVTRGRSICFGREQ:
205                cmUnpkRgrSiCfgReq(RgUiRgrSiCfgReq, pst, mBuf);
206                break;
207             case EVTRGRWARNINGSICFGREQ:
208                cmUnpkRgrWarningSiCfgReq(RgUiRgrWarningSiCfgReq, pst, mBuf);
209                break;
210
211             case EVTRGRWARNINGSISTOPREQ:
212                cmUnpkRgrWarningSiStopReq(RgUiRgrWarningSiStopReq, pst, mBuf);
213                break;
214 #endif/*RGR_SI_SCH */
215                /* LTE_ADV_FLAG_REMOVED_START */
216             case EVTRGRLOADINFREQ:
217                cmUnpkRgrLoadInfReq(RgUiRgrLoadInfReq, pst, mBuf);
218                break;
219                /* LTE_ADV_FLAG_REMOVED_END */
220 #endif            
221             default:
222                RGSCH_FREE_MSG(mBuf);
223                break;
224          }
225          break;
226       case ENTMAC: /* When MAC sends a msg to Scheduler instance */
227          switch(pst->event)
228          {
229 #ifdef LCSCH
230             case EVTINFDEDBOUPDTREQ:
231                cmUnpkMacSchDedBoUpdtReq(RgMacSchDedBoUpdtReq, pst, mBuf);
232                break;
233             case EVTINFCMNBOUPDTREQ:
234                cmUnpkMacSchCmnBoUpdtReq(RgMacSchCmnBoUpdtReq, pst, mBuf);
235                break;   
236             case EVTINFSFRECPIND:
237                cmUnpkMacSchSfRecpInd(RgMacSchSfRecpInd, pst, mBuf);
238                break;
239                /*Fix: start: Inform UE delete to scheduler*/
240             case EVTINFUEDELIND:
241                cmUnpkMacSchUeDelInd(RgMacSchUeDelInd, pst, mBuf);
242                break;
243             /*Fix: end: Inform UE delete to scheduler*/
244 #ifdef LTE_L2_MEAS
245             case EVTINFL2MEASCFM:
246                cmUnpkMacSchL2MeasCfm(RgMacSchL2MeasCfm, pst, mBuf);
247                break;
248             case EVTINFL2MEASSTOPCFM:
249                cmUnpkMacSchL2MeasCfm(RgMacSchL2MeasStopCfm, pst, mBuf);
250                break;
251 #endif
252 #endif            
253             case EVENT_SLOT_IND_TO_SCH:
254                unpackMacSchSlotInd(MacSchSlotInd, pst, mBuf);
255                break;
256             default:
257                RGSCH_FREE_MSG(mBuf);
258                break;
259          }
260          break;
261       case ENTRM: /* When RRM sends msg to scheduler */
262          switch(pst->event)
263          {
264             case EVTRGMBNDREQ:
265                cmUnpkRgmBndReq(RgUiRgmBndReq, pst, mBuf); 
266                break;
267             case EVTRGMUBNDREQ:
268                cmUnpkRgmUbndReq(RgUiRgmUbndReq, pst, mBuf); 
269                break;
270             case EVTRGMCFGPRBRPRT:
271                cmUnpkRgmCfgPrbRprt(RgUiRgmCfgPrbRprt, pst, mBuf);
272                break;
273             default:
274                RGSCH_FREE_MSG(mBuf);
275                break;
276          }
277          break;
278       default:
279           RGSCH_FREE_MSG(mBuf);
280           break;
281    }
282    ODU_EXIT_TASK();
283    return ROK;
284 }/* end of schActvTsk */
285
286 \f
287 /**********************************************************************
288  
289          End of file
290 **********************************************************************/