Moving all common header file into common_def.h file
[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 int unpackDuMacCellCfg(DuMacCellCfgReq func,Pst *pst,Buffer *mBuf);
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    TRC2(rgHdlSMEvents)
88
89    switch(pst->event)
90    {
91 #ifdef LCRGMILRG
92       case EVTLRGCFGREQ:
93          /* Process a config. request */
94          cmUnpkLrgCfgReq(RgMiLrgCfgReq, pst, mBuf);
95          break;
96       case EVTMACSCHGENCFGREQ:
97          /* Process a config. request */
98          cmUnpkLrgSchCfgReq(MacSchGenCfgReq, pst, mBuf);
99          break;
100       case EVTLRGCNTRLREQ:
101          /* Process a control request */
102          cmUnpkLrgCntrlReq(RgMiLrgCntrlReq, pst, mBuf);
103          break;
104       case EVTLRGSSTAREQ:
105          /* Process a status request  */
106          cmUnpkLrgStaReq(RgMiLrgStaReq, pst, mBuf);
107          break;
108       case EVTLRGSTSREQ:
109          /* Process a statistics request */
110          cmUnpkLrgStsReq(RgMiLrgStsReq, pst, mBuf);
111          break;
112 #endif /* LCRGMILRG */
113       case EVENT_MAC_CELL_CONFIG_REQ:
114          /* Process MAC cell config */
115          unpackDuMacCellCfg(MacHdlCellCfgReq, pst, mBuf);
116          break;
117       case EVENT_MAC_CELL_START_REQ:
118          /* Process MAC cell start request */
119          unpackMacCellStartReq(MacHdlCellStartReq, pst, mBuf);
120          break;
121                 case EVENT_MAC_CELL_STOP_REQ:
122                         /* Process MAC cell stop request */
123                         unpackMacCellStopReq(MacHdlCellStopReq, pst, mBuf);
124                         break;
125                 case EVENT_MAC_DL_CCCH_IND:
126                         /* Process DL CCCH Ind */
127                         unpackMacDlCcchInd(MacHdlDlCcchInd, pst, mBuf);
128                         break;
129                 case EVENT_MAC_UE_CREATE_REQ:
130                    /* Process Ue Create Request */
131                         unpackMacUeCreateReq(MacHdlUeCreateReq, pst, mBuf);
132                         break;
133       default:
134          RG_FREE_MSG(mBuf);
135          break;
136    }
137 }
138
139
140 /**
141  * @brief Task Activation callback function Entity NH. 
142  *
143  * @details
144  *
145  *     Function : rgHdlNHEvents
146  *     
147  *     Process Messages received from Entity NH
148  *     
149  *  @param[in]  Pst     *pst, Post structure of the primitive.     
150  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
151  *  @param[in]  Reason reason.
152  *  @return  void
153  **/
154 #ifdef ANSI
155 PRIVATE INLINE void rgHdlNHEvents
156 (
157 Pst     *pst,                       /* post structure       */
158 Buffer  *mBuf                       /* message buffer       */
159 )
160 #else
161 PRIVATE INLINE void rgHdlNHEvents(pst, mBuf)
162 Pst     *pst;                       /* post structure       */
163 Buffer  *mBuf;                      /* message buffer       */
164 #endif
165 {
166    TRC2(rgHdlNHEvents)
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    TRC2(rgHdlKWEvents)
214
215    switch(pst->event)
216    {
217 #ifdef LCRGUIRGU
218       case EVTRGUBNDREQ:
219          cmUnpkRguBndReq(RgUiRguBndReq, pst, mBuf);
220          break;
221       case EVTRGUUBNDREQ:
222          cmUnpkRguUbndReq(RgUiRguUbndReq, pst, mBuf);
223          break;
224       case EVTRLCDLDAT:
225          unpackDlData(MacRlcProcDlData, pst, mBuf);
226          break;
227       case EVTRLCBOSTA:
228          unpackBOStatus(MacRlcProcBOStatus, pst, mBuf);
229          break;
230 #ifdef LTE_L2_MEAS
231
232       case EVTRGUL2MULTHRPMEASREQ:
233          cmUnpkRguL2MUlThrpMeasReq(RgUiRguL2MUlThrpMeasReq, pst,mBuf);
234          break;
235
236 #endif
237 #endif            
238       default:
239          RG_FREE_MSG(mBuf);
240          break;
241    }
242 }
243
244 /**
245  * @brief Task Activation callback function Entity TF. 
246  *
247  * @details
248  *
249  *     Function : rgHdlTFEvents
250  *     
251  *     Process Messages received from Entity TF
252  *     
253  *  @param[in]  Pst     *pst, Post structure of the primitive.     
254  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
255  *  @param[in]  Reason reason.
256  *  @return  void
257  **/
258 #ifdef ANSI
259 PRIVATE INLINE void rgHdlTFEvents
260 (
261 Pst     *pst,                       /* post structure       */
262 Buffer  *mBuf                       /* message buffer       */
263 )
264 #else
265 PRIVATE INLINE void rgHdlTFEvents(pst, mBuf)
266 Pst     *pst;                       /* post structure       */
267 Buffer  *mBuf;                      /* message buffer       */
268 #endif
269 {
270    TRC2(rgHdlTFEvents)
271
272    switch(pst->event)
273    {
274 #if  (defined(LCRGLITFU) || defined(LWLCRGLITFU))
275       case EVTTFUBNDCFM:
276          cmUnpkTfuBndCfm(RgLiTfuBndCfm, pst, mBuf);
277          break;
278       case EVTTFUDATIND:
279          cmUnpkTfuDatInd(RgLiTfuDatInd, pst, mBuf);
280          break;
281       case EVENT_SLOT_IND_TO_MAC:
282          cmUnpackSlotInd(fapiMacSlotInd, pst, mBuf);
283          break;
284 #if defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
285       case EVTTFUNONRTIND:
286          cmUnpkTfuNonRtInd(RgLiTfuNonRtInd, pst, mBuf);
287          break;
288 #endif
289 #endif            
290       default:
291          RG_FREE_MSG(mBuf);
292          break;
293    }
294 }
295
296
297 /**
298  * @brief Task Activation callback function Entity RG SCH. 
299  *
300  * @details
301  *
302  *     Function : rgHdlRGEvents
303  *     
304  *     Process Messages received from Entity RG SCH
305  *     
306  *  @param[in]  Pst     *pst, Post structure of the primitive.     
307  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
308  *  @param[in]  Reason reason.
309  *  @return  void
310  **/
311 #ifdef ANSI
312 PRIVATE INLINE void rgHdlRGEvents
313 (
314 Pst     *pst,                       /* post structure       */
315 Buffer  *mBuf                       /* message buffer       */
316 )
317 #else
318 PRIVATE INLINE void rgHdlRGEvents(pst, mBuf)
319 Pst     *pst;                       /* post structure       */
320 Buffer  *mBuf;                      /* message buffer       */
321 #endif
322 {
323    TRC2(rgHdlRGEvents)
324
325    switch(pst->event)
326    {
327 #ifdef LCRG
328       case EVTINFCELLREGREQ:
329          cmUnpkSchMacCellRegReq(RgSchMacCellRegReq, pst, mBuf);
330          break;
331       case EVTINFSFALLOCREQ:
332          cmUnpkSchMacSfAllocReq(RgSchMacSfAllocReq, pst, mBuf);
333          break;
334       case EVTINFRLSHQREQ:
335          cmUnpkSchMacRlsHqReq(RgSchMacRlsHqReq, pst, mBuf);
336          break;
337       case EVTINFHQENTRESET:
338          cmUnpkSchMacRstHqEntReq(RgSchMacRstHqEntReq, pst, mBuf);
339          break;
340       case EVTINFRLSRNTIREQ:
341          cmUnpkSchMacRlsRntiReq(RgSchMacRlsRntiReq, pst, mBuf);
342          break;
343 #ifdef LTEMAC_SPS
344       case EVTINFSPSLCREG:
345          cmUnpkSchMacSpsLcRegReq(RgSchMacSpsLcRegReq, pst, mBuf);
346          break;
347       case EVTINFSPSLCDEREG:
348          cmUnpkSchMacSpsLcDeregReq(RgSchMacSpsLcDeregReq, pst, mBuf);
349          break;
350       case EVTINFSPSRESET:
351          cmUnpkSchMacUlSpsResetReq(RgSchMacUlSpsResetReq, pst, mBuf);
352          break;
353 #endif /* LTEMAC_SPS */
354 #ifdef LTE_L2_MEAS
355       case EVTINFL2MEASREQ:
356          cmUnpkSchMacL2MeasReq(RgSchMacL2MeasReq, pst, mBuf);
357          break;
358       case EVTINFL2MEASSENDREQ :
359          cmUnpkSchMacL2MeasSendReq(RgSchMacL2MeasSendReq, pst , mBuf);
360          break;
361       case EVTINFL2MEASSTOPREQ:
362          cmUnpkSchMacL2MeasStopReq(RgSchMacL2MeasStopReq, pst , mBuf);
363          break;
364 #endif/* LTE_L2_MEAS */
365       case EVTINFLCGREG:
366          cmUnpkSchMacLcgRegReq(RgSchMacLcgRegReq, pst, mBuf);
367          break;
368 #endif            
369 #if defined(LTE_ADV) && defined(LCPRG)
370       case EVTPRGUESCELLCFGREQ:
371       {
372          cmUnpkPrgPMacSMacUeSCellCfgReq(RgPrgPMacSMacUeSCellCfgReq, pst, mBuf);
373       }
374       break;
375       case EVTPRGUESCELLCFGCFM:
376       case EVTPRGUESCELLLCHMODCFM:
377       case EVTPRGUESCELLLCHDELCFMDEL:
378       case EVTPRGUESCELLLCHADDCFM:
379       {
380          cmUnpkPrgSMacPMacCfgCfm(RgPrgSMacPMacCfgCfm, pst, mBuf);
381       }
382       break;
383       case EVTPRGUESCELLDELREQ:
384       {
385          cmUnpkPrgPMacSMacUeSCellDelReq(RgPrgPMacSMacUeSCellDelReq, pst, mBuf);
386       }
387       break;
388       case EVTPRGUESCELLLCHMODREQ:
389       {
390          cmUnpkPrgPMacSMacUeSCellLchModReq(RgPrgPMacSMacUeSCellLchModReq, pst,
391                                            mBuf);
392       }
393       break;
394       case EVTPRGUESCELLLCHDELREQ:
395       {
396          cmUnpkPrgPMacSMacUeSCellLchDelReq(RgPrgPMacSMacUeSCellLchDelReq, pst,
397                                            mBuf);
398       }
399       break;
400       case EVTPRGUESCELLLCHADDREQ:
401       {
402          cmUnpkPrgPMacSMacUeSCellLchAddReq(RgPrgPMacSMacUeSCellLchAddReq, pst,
403                                            mBuf);
404       }
405       break;
406
407 #endif
408       default:
409       {
410          RG_FREE_MSG(mBuf);
411          break;
412       }
413
414    }
415 }
416
417
418 \f
419 /**
420  * @brief Task Activation callback function. 
421  *
422  * @details
423  *
424  *     Function : rgActvTsk
425  *     
426  *     Primitives invoked by MAC's users/providers through
427  *     a loosely coupled interface arrive here by means of 
428  *     SSI's message handling. This API is registered with
429  *     SSI during the Task Registration of MAC.
430  *     
431  *  @param[in]  Pst     *pst, Post structure of the primitive.     
432  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
433  *  @param[in]  Reason reason.
434  *  @return  S16
435  *      -# ROK
436  **/
437 #ifdef ANSI
438 PUBLIC S16 rgActvTsk
439 (
440 Pst     *pst,                       /* post structure       */
441 Buffer  *mBuf                       /* message buffer       */
442 )
443 #else
444 PUBLIC S16 rgActvTsk(pst, mBuf)
445 Pst     *pst;                       /* post structure       */
446 Buffer  *mBuf;                      /* message buffer       */
447 #endif
448 {
449    TRC2(rgActvTsk)
450
451    switch(pst->srcEnt)
452    {
453       /* The originator of this message is the stack manager,
454        * unpack and go to the respective primitive processing function */
455       case ENTDUAPP:
456           rgHdlSMEvents(pst, mBuf);
457            break;
458       case ENTNH:
459           rgHdlNHEvents(pst, mBuf);
460           break;
461       case ENTKW:
462           rgHdlKWEvents(pst, mBuf);
463           break;
464       case ENTTF:
465           rgHdlTFEvents(pst, mBuf);
466           break;
467       case ENTRG: /* When scheduler instance sends msg to MAC */
468           rgHdlRGEvents(pst, mBuf);
469           break;
470        default:
471           RG_FREE_MSG(mBuf);
472           break;
473    }
474    SExitTsk();
475    RETVALUE(ROK);
476 }/* end of rgActvTsk */
477
478 \f
479 /**********************************************************************
480  
481          End of file
482 **********************************************************************/