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