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