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