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