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