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