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