Initial commit for Bronze release
[o-du/l2.git] / src / 5gnrmac / rg_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_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 "rgu.h"           /* RGU defines */
48 #include "tfu.h"           /* RGU defines */
49 #include "lrg.h"           /* layer management defines for LTE-MAC */
50 #include "rgr.h"           /* layer management defines for LTE-MAC */
51 #include "crg.h"           /* CRG interface includes */
52 #include "rg_sch_inf.h"    /* SCH interface includes */
53 #include "rg_prg.h"        /* PRG interface includes */
54 #include "rg_env.h"        /* customisable defines and macros for LTE-MAC */
55 #include "rg.h"            /* defines and macros for MAC */
56 #include "rgr.h"            /* defines and macros for SCH */
57
58
59 /* header/extern include files (.x) */
60 #include "gen.x"           /* general layer typedefs */
61 #include "ssi.x"           /* system services typedefs */
62 #include "cm5.x"           /* common timers */
63 #include "cm_hash.x"       /* common hash list */
64 #include "cm_lib.x"        /* common library */
65 #include "cm_llist.x"      /* common linked list */
66 #include "cm_mblk.x"       /* memory management */
67 #include "cm_tkns.x"       /* common tokens */
68 #include "cm_lte.x"        /* common tokens */
69 #include "rgu.x"           /* RGU types */
70 #include "tfu.x"           /* RGU types */
71 #include "lrg.x"           /* layer management typedefs for MAC */
72 #include "rgr.x"           /* layer management typedefs for MAC */
73 #include "crg.x"           /* CRG interface typedes */
74 #include "rg_sch_inf.x"    /* SCH interface typedefs */
75 #include "rg_prg.x"        /*PRG interface includes*/
76 #include "rg.x"            /* typedefs for MAC */
77
78
79 /**
80  * @brief Task Activation callback function Entity SM. 
81  *
82  * @details
83  *
84  *     Function : rgHdlSMEvents
85  *     
86  *     Process Messages received from Entity SM
87  *     
88  *  @param[in]  Pst     *pst, Post structure of the primitive.     
89  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
90  *  @param[in]  Reason reason.
91  *  @return  void
92  **/
93 #ifdef ANSI
94 PRIVATE INLINE void rgHdlSMEvents
95 (
96 Pst     *pst,                       /* post structure       */
97 Buffer  *mBuf                       /* message buffer       */
98 )
99 #else
100 PRIVATE INLINE void rgHdlSMEvents(pst, mBuf)
101 Pst     *pst;                       /* post structure       */
102 Buffer  *mBuf;                      /* message buffer       */
103 #endif
104 {
105    TRC2(rgHdlSMEvents)
106
107    switch(pst->event)
108    {
109 #ifdef LCRGMILRG
110       case EVTLRGCFGREQ:
111          /* Process a config. request */
112          cmUnpkLrgCfgReq(RgMiLrgCfgReq, pst, mBuf);
113          break;
114       case EVTMACSCHGENCFGREQ:
115          /* Process a config. request */
116          cmUnpkLrgSchCfgReq(MacSchGenCfgReq, pst, mBuf);
117          break;
118       case EVTMACSCHCFGREQ: 
119          cmUnpkRgrCfgReq(MacSchCfgReq, pst, mBuf);
120          break;
121       case EVTLRGCNTRLREQ:
122          /* Process a control request */
123          cmUnpkLrgCntrlReq(RgMiLrgCntrlReq, pst, mBuf);
124          break;
125       case EVTLRGSSTAREQ:
126          /* Process a status request  */
127          cmUnpkLrgStaReq(RgMiLrgStaReq, pst, mBuf);
128          break;
129       case EVTLRGSTSREQ:
130          /* Process a statistics request */
131          cmUnpkLrgStsReq(RgMiLrgStsReq, pst, mBuf);
132          break;
133 #endif /* LCRGMILRG */
134       default:
135          RG_FREE_MSG(mBuf);
136          break;
137    }
138 }
139
140
141 /**
142  * @brief Task Activation callback function Entity NH. 
143  *
144  * @details
145  *
146  *     Function : rgHdlNHEvents
147  *     
148  *     Process Messages received from Entity NH
149  *     
150  *  @param[in]  Pst     *pst, Post structure of the primitive.     
151  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
152  *  @param[in]  Reason reason.
153  *  @return  void
154  **/
155 #ifdef ANSI
156 PRIVATE INLINE void rgHdlNHEvents
157 (
158 Pst     *pst,                       /* post structure       */
159 Buffer  *mBuf                       /* message buffer       */
160 )
161 #else
162 PRIVATE INLINE void rgHdlNHEvents(pst, mBuf)
163 Pst     *pst;                       /* post structure       */
164 Buffer  *mBuf;                      /* message buffer       */
165 #endif
166 {
167    TRC2(rgHdlNHEvents)
168
169    switch(pst->event)
170    {
171 #ifdef LCRGUICRG
172       case EVTCRGBNDREQ:
173          cmUnpkCrgBndReq(RgUiCrgBndReq, pst, mBuf);
174          break;
175       case EVTCRGUBNDREQ:
176          cmUnpkCrgUbndReq(RgUiCrgUbndReq, pst, mBuf);
177          break;
178       case EVTCRGCFGREQ:
179          cmUnpkCrgCfgReq(RgUiCrgCfgReq, pst, mBuf);
180          break;
181 #endif            
182       default:
183          RG_FREE_MSG(mBuf);
184          break;
185    }
186 }
187
188 /**
189  * @brief Task Activation callback function Entity KW. 
190  *
191  * @details
192  *
193  *     Function : rgHdlKWEvents
194  *     
195  *     Process Messages received from Entity KW
196  *     
197  *  @param[in]  Pst     *pst, Post structure of the primitive.     
198  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
199  *  @param[in]  Reason reason.
200  *  @return  void
201  **/
202 #ifdef ANSI
203 PRIVATE INLINE void rgHdlKWEvents
204 (
205 Pst     *pst,                       /* post structure       */
206 Buffer  *mBuf                       /* message buffer       */
207 )
208 #else
209 PRIVATE INLINE void rgHdlKWEvents(pst, mBuf)
210 Pst     *pst;                       /* post structure       */
211 Buffer  *mBuf;                      /* message buffer       */
212 #endif
213 {
214    TRC2(rgHdlKWEvents)
215
216    switch(pst->event)
217    {
218 #ifdef LCRGUIRGU
219       case EVTRGUBNDREQ:
220          cmUnpkRguBndReq(RgUiRguBndReq, pst, mBuf);
221          break;
222       case EVTRGUUBNDREQ:
223          cmUnpkRguUbndReq(RgUiRguUbndReq, pst, mBuf);
224          break;
225       case EVTRGUCDATREQ:
226          cmUnpkRguCDatReq(RgUiRguCDatReq, pst, mBuf);
227          break;
228       case EVTRGUDDATREQ:
229          cmUnpkRguDDatReq(RgUiRguDDatReq, pst, mBuf);
230          break;
231       case EVTRGUCSTARSP:
232          cmUnpkRguCStaRsp(RgUiRguCStaRsp, pst, mBuf);
233          break;
234       case EVTRGUDSTARSP:
235          cmUnpkRguDStaRsp(RgUiRguDStaRsp, pst, mBuf);
236          break;
237 #ifdef LTE_L2_MEAS
238
239       case EVTRGUL2MULTHRPMEASREQ:
240          cmUnpkRguL2MUlThrpMeasReq(RgUiRguL2MUlThrpMeasReq, pst,mBuf);
241          break;
242
243 #endif
244 #endif            
245       default:
246          RG_FREE_MSG(mBuf);
247          break;
248    }
249 }
250
251 /**
252  * @brief Task Activation callback function Entity TF. 
253  *
254  * @details
255  *
256  *     Function : rgHdlTFEvents
257  *     
258  *     Process Messages received from Entity TF
259  *     
260  *  @param[in]  Pst     *pst, Post structure of the primitive.     
261  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
262  *  @param[in]  Reason reason.
263  *  @return  void
264  **/
265 #ifdef ANSI
266 PRIVATE INLINE void rgHdlTFEvents
267 (
268 Pst     *pst,                       /* post structure       */
269 Buffer  *mBuf                       /* message buffer       */
270 )
271 #else
272 PRIVATE INLINE void rgHdlTFEvents(pst, mBuf)
273 Pst     *pst;                       /* post structure       */
274 Buffer  *mBuf;                      /* message buffer       */
275 #endif
276 {
277    TRC2(rgHdlTFEvents)
278
279    switch(pst->event)
280    {
281 #if  (defined(LCRGLITFU) || defined(LWLCRGLITFU))
282       case EVTTFUBNDCFM:
283          cmUnpkTfuBndCfm(RgLiTfuBndCfm, pst, mBuf);
284          break;
285       case EVTTFUDATIND:
286          cmUnpkTfuDatInd(RgLiTfuDatInd, pst, mBuf);
287          break;
288       case EVTTFUTTIIND:
289          cmUnpkTfuTtiInd(RgLiTfuTtiInd, pst, mBuf);
290          break;
291 #if defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
292       case EVTTFUNONRTIND:
293          cmUnpkTfuNonRtInd(RgLiTfuNonRtInd, pst, mBuf);
294          break;
295 #endif
296 #endif            
297       default:
298          RG_FREE_MSG(mBuf);
299          break;
300    }
301 }
302
303
304 /**
305  * @brief Task Activation callback function Entity RG SCH. 
306  *
307  * @details
308  *
309  *     Function : rgHdlRGEvents
310  *     
311  *     Process Messages received from Entity RG SCH
312  *     
313  *  @param[in]  Pst     *pst, Post structure of the primitive.     
314  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
315  *  @param[in]  Reason reason.
316  *  @return  void
317  **/
318 #ifdef ANSI
319 PRIVATE INLINE void rgHdlRGEvents
320 (
321 Pst     *pst,                       /* post structure       */
322 Buffer  *mBuf                       /* message buffer       */
323 )
324 #else
325 PRIVATE INLINE void rgHdlRGEvents(pst, mBuf)
326 Pst     *pst;                       /* post structure       */
327 Buffer  *mBuf;                      /* message buffer       */
328 #endif
329 {
330    TRC2(rgHdlRGEvents)
331
332    switch(pst->event)
333    {
334 #ifdef LCRG
335       case EVTINFCELLREGREQ:
336          cmUnpkSchMacCellRegReq(RgSchMacCellRegReq, pst, mBuf);
337          break;
338       case EVTINFSFALLOCREQ:
339          cmUnpkSchMacSfAllocReq(RgSchMacSfAllocReq, pst, mBuf);
340          break;
341       case EVTINFRLSHQREQ:
342          cmUnpkSchMacRlsHqReq(RgSchMacRlsHqReq, pst, mBuf);
343          break;
344       case EVTINFHQENTRESET:
345          cmUnpkSchMacRstHqEntReq(RgSchMacRstHqEntReq, pst, mBuf);
346          break;
347       case EVTINFRLSRNTIREQ:
348          cmUnpkSchMacRlsRntiReq(RgSchMacRlsRntiReq, pst, mBuf);
349          break;
350 #ifdef LTEMAC_SPS
351       case EVTINFSPSLCREG:
352          cmUnpkSchMacSpsLcRegReq(RgSchMacSpsLcRegReq, pst, mBuf);
353          break;
354       case EVTINFSPSLCDEREG:
355          cmUnpkSchMacSpsLcDeregReq(RgSchMacSpsLcDeregReq, pst, mBuf);
356          break;
357       case EVTINFSPSRESET:
358          cmUnpkSchMacUlSpsResetReq(RgSchMacUlSpsResetReq, pst, mBuf);
359          break;
360 #endif /* LTEMAC_SPS */
361 #ifdef LTE_L2_MEAS
362       case EVTINFL2MEASREQ:
363          cmUnpkSchMacL2MeasReq(RgSchMacL2MeasReq, pst, mBuf);
364          break;
365       case EVTINFL2MEASSENDREQ :
366          cmUnpkSchMacL2MeasSendReq(RgSchMacL2MeasSendReq, pst , mBuf);
367          break;
368       case EVTINFL2MEASSTOPREQ:
369          cmUnpkSchMacL2MeasStopReq(RgSchMacL2MeasStopReq, pst , mBuf);
370          break;
371 #endif/* LTE_L2_MEAS */
372       case EVTINFLCGREG:
373          cmUnpkSchMacLcgRegReq(RgSchMacLcgRegReq, pst, mBuf);
374          break;
375 #endif            
376 #if defined(LTE_ADV) && defined(LCPRG)
377       case EVTPRGUESCELLCFGREQ:
378       {
379          cmUnpkPrgPMacSMacUeSCellCfgReq(RgPrgPMacSMacUeSCellCfgReq, pst, mBuf);
380       }
381       break;
382       case EVTPRGUESCELLCFGCFM:
383       case EVTPRGUESCELLLCHMODCFM:
384       case EVTPRGUESCELLLCHDELCFMDEL:
385       case EVTPRGUESCELLLCHADDCFM:
386       {
387          cmUnpkPrgSMacPMacCfgCfm(RgPrgSMacPMacCfgCfm, pst, mBuf);
388       }
389       break;
390       case EVTPRGUESCELLDELREQ:
391       {
392          cmUnpkPrgPMacSMacUeSCellDelReq(RgPrgPMacSMacUeSCellDelReq, pst, mBuf);
393       }
394       break;
395       case EVTPRGUESCELLLCHMODREQ:
396       {
397          cmUnpkPrgPMacSMacUeSCellLchModReq(RgPrgPMacSMacUeSCellLchModReq, pst,
398                                            mBuf);
399       }
400       break;
401       case EVTPRGUESCELLLCHDELREQ:
402       {
403          cmUnpkPrgPMacSMacUeSCellLchDelReq(RgPrgPMacSMacUeSCellLchDelReq, pst,
404                                            mBuf);
405       }
406       break;
407       case EVTPRGUESCELLLCHADDREQ:
408       {
409          cmUnpkPrgPMacSMacUeSCellLchAddReq(RgPrgPMacSMacUeSCellLchAddReq, pst,
410                                            mBuf);
411       }
412       break;
413
414 #endif
415       default:
416       {
417          RG_FREE_MSG(mBuf);
418          break;
419       }
420
421    }
422 }
423
424
425 \f
426 /**
427  * @brief Task Activation callback function. 
428  *
429  * @details
430  *
431  *     Function : rgActvTsk
432  *     
433  *     Primitives invoked by MAC's users/providers through
434  *     a loosely coupled interface arrive here by means of 
435  *     SSI's message handling. This API is registered with
436  *     SSI during the Task Registration of MAC.
437  *     
438  *  @param[in]  Pst     *pst, Post structure of the primitive.     
439  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
440  *  @param[in]  Reason reason.
441  *  @return  S16
442  *      -# ROK
443  **/
444 #ifdef ANSI
445 PUBLIC S16 rgActvTsk
446 (
447 Pst     *pst,                       /* post structure       */
448 Buffer  *mBuf                       /* message buffer       */
449 )
450 #else
451 PUBLIC S16 rgActvTsk(pst, mBuf)
452 Pst     *pst;                       /* post structure       */
453 Buffer  *mBuf;                      /* message buffer       */
454 #endif
455 {
456    TRC2(rgActvTsk)
457
458    switch(pst->srcEnt)
459    {
460       /* The originator of this message is the stack manager,
461        * unpack and go to the respective primitive processing function */
462       case ENTDUAPP:
463           rgHdlSMEvents(pst, mBuf);
464            break;
465       case ENTNH:
466           rgHdlNHEvents(pst, mBuf);
467           break;
468       case ENTKW:
469           rgHdlKWEvents(pst, mBuf);
470           break;
471       case ENTTF:
472           rgHdlTFEvents(pst, mBuf);
473           break;
474       case ENTRG: /* When scheduler instance sends msg to MAC */
475           rgHdlRGEvents(pst, mBuf);
476           break;
477        default:
478           RG_FREE_MSG(mBuf);
479           break;
480    }
481    SExitTsk();
482    RETVALUE(ROK);
483 }/* end of rgActvTsk */
484
485 \f
486 /**********************************************************************
487  
488          End of file
489 **********************************************************************/