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