Merge "Documentation fixes"
[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 #ifdef ANSI
77 static inline void rgHdlSMEvents
78 (
79 Pst     *pst,                       /* post structure       */
80 Buffer  *mBuf                       /* message buffer       */
81 )
82 #else
83 static inline void rgHdlSMEvents(pst, mBuf)
84 Pst     *pst;                       /* post structure       */
85 Buffer  *mBuf;                      /* message buffer       */
86 #endif
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       case EVENT_MAC_UE_RECONFIG_REQ:
133          /* Process Ue Reconfig Request */
134          unpackMacUeReconfigReq(MacProcUeReconfigReq, pst, mBuf);
135          break;
136       default:
137          RG_FREE_MSG(mBuf);
138          break;
139    }
140 }
141
142
143 /**
144  * @brief Task Activation callback function Entity NH. 
145  *
146  * @details
147  *
148  *     Function : rgHdlNHEvents
149  *     
150  *     Process Messages received from Entity NH
151  *     
152  *  @param[in]  Pst     *pst, Post structure of the primitive.     
153  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
154  *  @param[in]  Reason reason.
155  *  @return  void
156  **/
157 #ifdef ANSI
158 static inline void rgHdlNHEvents
159 (
160 Pst     *pst,                       /* post structure       */
161 Buffer  *mBuf                       /* message buffer       */
162 )
163 #else
164 static inline void rgHdlNHEvents(pst, mBuf)
165 Pst     *pst;                       /* post structure       */
166 Buffer  *mBuf;                      /* message buffer       */
167 #endif
168 {
169    switch(pst->event)
170    {
171 #ifdef LCRGUICRG
172       case EVTCRGBNDREQ:
173          cmUnpkCrgBndReq(RgUiCrgBndReq, pst, mBuf);
174          break;
175       case EVTCRGUBNDREQ:
176          cmUnpkCrgUbndReq(RgUiCrgUbndReq, pst, mBuf);
177          break;
178       case EVTCRGCFGREQ:
179          cmUnpkCrgCfgReq(RgUiCrgCfgReq, pst, mBuf);
180          break;
181 #endif            
182       default:
183          RG_FREE_MSG(mBuf);
184          break;
185    }
186 }
187
188 /**
189  * @brief Task Activation callback function Entity KW. 
190  *
191  * @details
192  *
193  *     Function : rgHdlKWEvents
194  *     
195  *     Process Messages received from Entity KW
196  *     
197  *  @param[in]  Pst     *pst, Post structure of the primitive.     
198  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
199  *  @param[in]  Reason reason.
200  *  @return  void
201  **/
202 #ifdef ANSI
203 static inline void rgHdlKWEvents
204 (
205 Pst     *pst,                       /* post structure       */
206 Buffer  *mBuf                       /* message buffer       */
207 )
208 #else
209 static inline void rgHdlKWEvents(pst, mBuf)
210 Pst     *pst;                       /* post structure       */
211 Buffer  *mBuf;                      /* message buffer       */
212 #endif
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 EVENT_DL_DATA_TO_MAC:
224          unpackRlcDlData(MacProcRlcDlData, pst, mBuf);
225          break;
226       case EVENT_BO_STATUS_TO_MAC:
227          unpackRlcBoStatus(MacProcRlcBoStatus, 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 static inline void rgHdlTFEvents
259 (
260 Pst     *pst,                       /* post structure       */
261 Buffer  *mBuf                       /* message buffer       */
262 )
263 #else
264 static inline void rgHdlTFEvents(pst, mBuf)
265 Pst     *pst;                       /* post structure       */
266 Buffer  *mBuf;                      /* message buffer       */
267 #endif
268 {
269    switch(pst->event)
270    {
271       case EVENT_SLOT_IND_TO_MAC:
272          unpackSlotInd(fapiMacSlotInd, pst, mBuf);
273          break;
274       case EVENT_STOP_IND_TO_MAC:
275          unpackStopInd(fapiMacStopInd, pst, mBuf);
276          break;
277       case EVENT_RACH_IND_TO_MAC:
278          unpackRachInd(fapiMacRachInd, pst, mBuf);
279          break;
280       case EVENT_CRC_IND_TO_MAC:
281          unpackCrcInd(fapiMacCrcInd, pst, mBuf);
282          break;
283       case EVENT_RX_DATA_IND_TO_MAC:
284          unpackRxDataInd(fapiMacRxDataInd, pst, mBuf);
285          break;
286       case EVENT_UCI_IND_TO_MAC:
287          unpackUciInd(FapiMacUciInd, pst, mBuf);
288          break;
289       default:
290          RG_FREE_MSG(mBuf);
291          break;
292    }
293 }
294
295
296 /**
297  * @brief Task Activation callback function Entity RG SCH. 
298  *
299  * @details
300  *
301  *     Function : rgHdlRGEvents
302  *     
303  *     Process Messages received from Entity RG SCH
304  *     
305  *  @param[in]  Pst     *pst, Post structure of the primitive.     
306  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
307  *  @param[in]  Reason reason.
308  *  @return  void
309  **/
310 #ifdef ANSI
311 static inline void rgHdlRGEvents
312 (
313 Pst     *pst,                       /* post structure       */
314 Buffer  *mBuf                       /* message buffer       */
315 )
316 #else
317 static inline void rgHdlRGEvents(pst, mBuf)
318 Pst     *pst;                       /* post structure       */
319 Buffer  *mBuf;                      /* message buffer       */
320 #endif
321 {
322    switch(pst->event)
323    {
324 #ifdef LCRG
325       case EVTINFCELLREGREQ:
326          cmUnpkSchMacCellRegReq(RgSchMacCellRegReq, pst, mBuf);
327          break;
328       case EVTINFSFALLOCREQ:
329          cmUnpkSchMacSfAllocReq(RgSchMacSfAllocReq, pst, mBuf);
330          break;
331       case EVTINFRLSHQREQ:
332          cmUnpkSchMacRlsHqReq(RgSchMacRlsHqReq, pst, mBuf);
333          break;
334       case EVTINFHQENTRESET:
335          cmUnpkSchMacRstHqEntReq(RgSchMacRstHqEntReq, pst, mBuf);
336          break;
337       case EVTINFRLSRNTIREQ:
338          cmUnpkSchMacRlsRntiReq(RgSchMacRlsRntiReq, pst, mBuf);
339          break;
340 #ifdef LTEMAC_SPS
341       case EVTINFSPSLCREG:
342          cmUnpkSchMacSpsLcRegReq(RgSchMacSpsLcRegReq, pst, mBuf);
343          break;
344       case EVTINFSPSLCDEREG:
345          cmUnpkSchMacSpsLcDeregReq(RgSchMacSpsLcDeregReq, pst, mBuf);
346          break;
347       case EVTINFSPSRESET:
348          cmUnpkSchMacUlSpsResetReq(RgSchMacUlSpsResetReq, pst, mBuf);
349          break;
350 #endif /* LTEMAC_SPS */
351 #ifdef LTE_L2_MEAS
352       case EVTINFL2MEASREQ:
353          cmUnpkSchMacL2MeasReq(RgSchMacL2MeasReq, pst, mBuf);
354          break;
355       case EVTINFL2MEASSENDREQ :
356          cmUnpkSchMacL2MeasSendReq(RgSchMacL2MeasSendReq, pst , mBuf);
357          break;
358       case EVTINFL2MEASSTOPREQ:
359          cmUnpkSchMacL2MeasStopReq(RgSchMacL2MeasStopReq, pst , mBuf);
360          break;
361 #endif/* LTE_L2_MEAS */
362       case EVTINFLCGREG:
363          cmUnpkSchMacLcgRegReq(RgSchMacLcgRegReq, pst, mBuf);
364          break;
365 #endif            
366 #if defined(LTE_ADV) && defined(LCPRG)
367       case EVTPRGUESCELLCFGREQ:
368       {
369          cmUnpkPrgPMacSMacUeSCellCfgReq(RgPrgPMacSMacUeSCellCfgReq, pst, mBuf);
370       }
371       break;
372       case EVTPRGUESCELLCFGCFM:
373       case EVTPRGUESCELLLCHMODCFM:
374       case EVTPRGUESCELLLCHDELCFMDEL:
375       case EVTPRGUESCELLLCHADDCFM:
376       {
377          cmUnpkPrgSMacPMacCfgCfm(RgPrgSMacPMacCfgCfm, pst, mBuf);
378       }
379       break;
380       case EVTPRGUESCELLDELREQ:
381       {
382          cmUnpkPrgPMacSMacUeSCellDelReq(RgPrgPMacSMacUeSCellDelReq, pst, mBuf);
383       }
384       break;
385       case EVTPRGUESCELLLCHMODREQ:
386       {
387          cmUnpkPrgPMacSMacUeSCellLchModReq(RgPrgPMacSMacUeSCellLchModReq, pst,
388                                            mBuf);
389       }
390       break;
391       case EVTPRGUESCELLLCHDELREQ:
392       {
393          cmUnpkPrgPMacSMacUeSCellLchDelReq(RgPrgPMacSMacUeSCellLchDelReq, pst,
394                                            mBuf);
395       }
396       break;
397       case EVTPRGUESCELLLCHADDREQ:
398       {
399          cmUnpkPrgPMacSMacUeSCellLchAddReq(RgPrgPMacSMacUeSCellLchAddReq, pst,
400                                            mBuf);
401       }
402       break;
403
404 #endif
405       default:
406       {
407          RG_FREE_MSG(mBuf);
408          break;
409       }
410
411    }
412 }
413
414
415 \f
416 /**
417  * @brief Task Activation callback function. 
418  *
419  * @details
420  *
421  *     Function : rgActvTsk
422  *     
423  *     Primitives invoked by MAC's users/providers through
424  *     a loosely coupled interface arrive here by means of 
425  *     SSI's message handling. This API is registered with
426  *     SSI during the Task Registration of MAC.
427  *     
428  *  @param[in]  Pst     *pst, Post structure of the primitive.     
429  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
430  *  @param[in]  Reason reason.
431  *  @return  S16
432  *      -# ROK
433  **/
434 #ifdef ANSI
435 S16 rgActvTsk
436 (
437 Pst     *pst,                       /* post structure       */
438 Buffer  *mBuf                       /* message buffer       */
439 )
440 #else
441 S16 rgActvTsk(pst, mBuf)
442 Pst     *pst;                       /* post structure       */
443 Buffer  *mBuf;                      /* message buffer       */
444 #endif
445 {
446    switch(pst->srcEnt)
447    {
448       /* The originator of this message is the stack manager,
449        * unpack and go to the respective primitive processing function */
450       case ENTDUAPP:
451           rgHdlSMEvents(pst, mBuf);
452            break;
453       case ENTNH:
454           rgHdlNHEvents(pst, mBuf);
455           break;
456       case ENTRLC:
457           rgHdlKWEvents(pst, mBuf);
458           break;
459       case ENTLWRMAC:
460           rgHdlTFEvents(pst, mBuf);
461           break;
462       case ENTMAC: /* When scheduler instance sends msg to MAC */
463           rgHdlRGEvents(pst, mBuf);
464           break;
465        default:
466           RG_FREE_MSG(mBuf);
467           break;
468    }
469    ODU_EXIT_TASK();
470    return ROK;
471 }/* end of rgActvTsk */
472
473 \f
474 /**********************************************************************
475  
476          End of file
477 **********************************************************************/