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