e6015b4bcc3ddffab05c69e2a67ee42dde898a65
[o-du/l2.git] / src / 5gnrsch / rg_sch_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 /************************************************************************
20  
21      Name:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code SSI Interface Implementation
26   
27      File:     rg_sch_ex_ms.c 
28   
29 **********************************************************************/
30
31 /** @file rg_ex_ms.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 "envopt.h"        /* environment options */
37 #include "envdep.h"        /* environment dependent */
38 #include "envind.h"        /* environment independent */
39 #include "gen.h"           /* general layer */
40 #include "ssi.h"           /* system services */
41 #include "cm5.h"           /* common timers defines */
42 #include "cm_hash.h"       /* common hash list defines */
43 #include "cm_llist.h"      /* common linked list defines */
44 #include "cm_mblk.h"       /* memory management */
45 #include "cm_tkns.h"       /* common tokens */
46 #include "cm_lte.h"       /* common tokens */
47 #include "tfu.h"           /* RGU defines */
48 #include "lrg.h"           /* layer management defines for LTE-MAC */
49 #include "rgr.h"           /* layer management defines for LTE-MAC */
50 #include "rgm.h"           /* layer management defines for LTE-MAC */
51 #include "rg_env.h"        /* customisable defines and macros for LTE-MAC */
52 #include "rg_sch_err.h"        /* defines and macros for Scheduler */
53 #include "rg_sch_inf.h"        /* defines and macros for Scheduler */
54 #include "rg_sch.h"        /* defines and macros for Scheduler */
55
56
57 /* header/extern include files (.x) */
58 #include "gen.x"           /* general layer typedefs */
59 #include "ssi.x"           /* system services typedefs */
60 #include "cm5.x"           /* common timers */
61 #include "cm_hash.x"       /* common hash list */
62 #include "cm_lib.x"        /* common library */
63 #include "cm_llist.x"      /* common linked list */
64 #include "cm_mblk.x"       /* memory management */
65 #include "cm_tkns.x"       /* common tokens */
66 #include "cm_lte.x"       /* common tokens */
67 #include "tfu.x"           /* RGU types */
68 #include "lrg.x"           /* layer management typedefs for MAC */
69 #include "rgr.x"           /* layer management typedefs for MAC */
70 #include "rgm.x"           /* layer management typedefs for MAC */
71 #include "rg_sch_inf.x"        /* typedefs for Scheduler */
72 #include "rg_sch.x"        /* typedefs for Scheduler */
73
74
75
76 \f
77 /**
78  * @brief Task Activation callback function. 
79  *
80  * @details
81  *
82  *     Function : schActvTsk
83  *     
84  *     Primitives invoked by MAC's users/providers through
85  *     a loosely coupled interface arrive here by means of 
86  *     SSI's message handling. This API is registered with
87  *     SSI during the Task Registration of MAC.
88  *     
89  *  @param[in]  Pst     *pst, post structure of the Primitive.     
90  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
91  *  @param[in]  Reason reason.
92  *  @return  S16
93  *      -# ROK
94  **/
95 #ifdef ANSI
96 PUBLIC S16 schActvTsk
97 (
98 Pst     *pst,                       /* post structure       */
99 Buffer  *mBuf                       /* message buffer       */
100 )
101 #else
102 PUBLIC S16 schActvTsk(pst, mBuf)
103 Pst     *pst;                       /* post structure       */
104 Buffer  *mBuf;                      /* message buffer       */
105 #endif
106 {
107    TRC2(schActvTsk)
108
109    switch(pst->srcEnt)
110    {
111       /* The originator of this message is the stack manager,
112        * unpack and go to the respective primitive processing function */
113       case ENTSM:
114          switch(pst->event)
115          {
116 #ifdef LCRGMILRG
117             case EVTMACSCHGENCFGREQ:
118                /* Process a config. request */
119                cmUnpkLrgSchCfgReq(HandleSchGenCfgReq, pst, mBuf);
120                break;
121             case EVTLRGSCHCNTRLREQ:
122                /* Process a control request */
123                cmUnpkLrgSchCntrlReq(RgMiLrgSchCntrlReq, pst, mBuf);
124                break;
125             case EVTLRGSCHSTAIND:
126                /* Process a control request */
127                cmUnpkLrgSchStaInd(RgMiLrgSchStaInd, pst, mBuf);
128                break;
129 #ifdef LTE_L2_MEAS
130             case EVTLRGSCHL2MEASREQ:
131                /* Process L2 Measurement request */
132                cmUnpkLrgSchL2MeasReq(RgMiLrgSchL2MeasReq, pst, mBuf);
133                break;
134             case EVTLRGSCHL2MEASSTOPREQ:
135                /* Process L2 Measurement Stop request */
136                cmUnpkLrgSchL2MeasStopReq(RgMiLrgSchL2MeasStopReq, pst, mBuf);
137                break;
138             case EVTLRGSCHL2MEASSENDREQ:
139                /* Process L2 Measurement Send  request */
140                cmUnpkLrgSchL2MeasSendReq(RgMiLrgSchL2MeasSendReq, pst, mBuf);
141                break;
142 #endif
143 #endif /* LCRGMILRG */
144             default:
145                RGSCH_FREE_MSG(mBuf);
146                break;
147          }
148          break;
149      case ENTNX:
150          switch(pst->event)
151          {
152 #ifdef LCRGUIRGR
153             case EVTRGRBNDREQ:
154                cmUnpkRgrBndReq(RgUiRgrBndReq, pst, mBuf);
155                break;
156             case EVTRGRUBNDREQ:
157                cmUnpkRgrUbndReq(RgUiRgrUbndReq, pst, mBuf);
158                break;
159 #ifdef RGR_SI_SCH
160             case EVTRGRSICFGREQ:
161                cmUnpkRgrSiCfgReq(RgUiRgrSiCfgReq, pst, mBuf);
162                break;
163             case EVTRGRWARNINGSICFGREQ:
164                cmUnpkRgrWarningSiCfgReq(RgUiRgrWarningSiCfgReq, pst, mBuf);
165                break;
166
167             case EVTRGRWARNINGSISTOPREQ:
168                cmUnpkRgrWarningSiStopReq(RgUiRgrWarningSiStopReq, pst, mBuf);
169                break;
170 #endif/*RGR_SI_SCH */
171                /* LTE_ADV_FLAG_REMOVED_START */
172             case EVTRGRLOADINFREQ:
173                cmUnpkRgrLoadInfReq(RgUiRgrLoadInfReq, pst, mBuf);
174                break;
175                /* LTE_ADV_FLAG_REMOVED_END */
176 #endif            
177             default:
178                RGSCH_FREE_MSG(mBuf);
179                break;
180          }
181          break;
182       case ENTTF:
183          switch(pst->event)
184          {
185 /*#ifdef LCRGLITFU L2Split */
186 #if (defined(LCRGLITFU) || defined(LWLCRGLITFU)) 
187             case EVTTFUSCHBNDCFM:
188                cmUnpkTfuBndCfm(RgLiTfuSchBndCfm, pst, mBuf);
189                break;
190             case EVTTFURAREQIND:
191                cmUnpkTfuRaReqInd(RgLiTfuRaReqInd, pst, mBuf);
192                break;
193             case EVTTFUULCQIIND:
194                cmUnpkTfuUlCqiInd(RgLiTfuUlCqiInd, pst, mBuf);
195                break;
196             case EVTTFUHQIND:
197                cmUnpkTfuHqInd(RgLiTfuHqInd, pst, mBuf);
198                break;
199             case EVTTFUSRIND:
200                cmUnpkTfuSrInd(RgLiTfuSrInd, pst, mBuf);
201                break;
202             case EVTTFUDLCQIIND:
203                cmUnpkTfuDlCqiInd(RgLiTfuDlCqiInd, pst, mBuf);
204                break;
205             case EVTTFUCRCIND:
206                /*cmUnpkTfuCrcIndInfo(RgLiTfuCrcInd, pst, mBuf); */
207                cmUnpkTfuCrcInd(RgLiTfuCrcInd, pst, mBuf);
208                break;
209             case EVTTFUTIMINGADVIND:
210                cmUnpkTfuTimingAdvInd(RgLiTfuTimingAdvInd, pst, mBuf);
211                break;
212             case EVTTFUPUCCHDELPWR:
213                cmUnpkTfuPucchDeltaPwr(RgLiTfuPucchDeltaPwrInd, pst, mBuf);
214                break;
215             case EVTTFUDOAIND:
216                cmUnpkTfuDoaInd(RgLiTfuDoaInd, pst, mBuf);
217                break;
218 #ifdef TFU_UPGRADE
219             case EVTTFURAWCQIIND:
220                cmUnpkTfuRawCqiInd(RgLiTfuRawCqiInd, pst, mBuf);
221                break;
222             case EVTTFUSRSIND:
223                cmUnpkTfuSrsInd(RgLiTfuSrsInd, pst, mBuf);
224                break;
225 #endif 
226                /*LAA: Error Indication on SCell*/
227             case EVTTFUERRIND:
228                cmUnpkTfuErrInd(RgLiTfuErrInd, pst, mBuf);
229                break;
230 #endif            
231             default:
232                RGSCH_FREE_MSG(mBuf);
233                break;
234          }
235          break;
236       case ENTRG: /* When MAC sends a msg to Scheduler instance */
237          switch(pst->event)
238          {
239 #ifdef LCSCH
240             case EVTINFDEDBOUPDTREQ:
241                cmUnpkMacSchDedBoUpdtReq(RgMacSchDedBoUpdtReq, pst, mBuf);
242                break;
243             case EVTINFCMNBOUPDTREQ:
244                cmUnpkMacSchCmnBoUpdtReq(RgMacSchCmnBoUpdtReq, pst, mBuf);
245                break;   
246             case EVTINFSFRECPIND:
247                cmUnpkMacSchSfRecpInd(RgMacSchSfRecpInd, pst, mBuf);
248                break;
249                /*Fix: start: Inform UE delete to scheduler*/
250             case EVTINFUEDELIND:
251                cmUnpkMacSchUeDelInd(RgMacSchUeDelInd, pst, mBuf);
252                break;
253             /*Fix: end: Inform UE delete to scheduler*/
254 #ifdef LTE_L2_MEAS
255             case EVTINFL2MEASCFM:
256                cmUnpkMacSchL2MeasCfm(RgMacSchL2MeasCfm, pst, mBuf);
257                break;
258             case EVTINFL2MEASSTOPCFM:
259                cmUnpkMacSchL2MeasCfm(RgMacSchL2MeasStopCfm, pst, mBuf);
260                break;
261 #endif
262 #endif            
263             case EVENT_SLOT_IND_TO_SCH:
264                cmUnpackMacSchSlotInd(macSchSlotInd, pst, mBuf);
265                break;
266             default:
267                RGSCH_FREE_MSG(mBuf);
268                break;
269          }
270          break;
271       case ENTRM: /* When RRM sends msg to scheduler */
272          switch(pst->event)
273          {
274             case EVTRGMBNDREQ:
275                cmUnpkRgmBndReq(RgUiRgmBndReq, pst, mBuf); 
276                break;
277             case EVTRGMUBNDREQ:
278                cmUnpkRgmUbndReq(RgUiRgmUbndReq, pst, mBuf); 
279                break;
280             case EVTRGMCFGPRBRPRT:
281                cmUnpkRgmCfgPrbRprt(RgUiRgmCfgPrbRprt, pst, mBuf);
282                break;
283             default:
284                RGSCH_FREE_MSG(mBuf);
285                break;
286          }
287          break;
288       default:
289           RGSCH_FREE_MSG(mBuf);
290           break;
291    }
292    SExitTsk();
293    RETVALUE(ROK);
294 }/* end of schActvTsk */
295
296 \f
297 /**********************************************************************
298  
299          End of file
300 **********************************************************************/