Initial commit
[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 "envopt.h"        /* environment options */
37 #include "envdep.h"        /* environment dependent */
38 #include "envind.h"        /* environment independent */
39 #include "gen.h"           /* general layer */
40 #include "ssi.h"           /* system services */
41 #include "cm5.h"           /* common timers defines */
42 #include "cm_hash.h"       /* common hash list defines */
43 #include "cm_llist.h"      /* common linked list defines */
44 #include "cm_mblk.h"       /* memory management */
45 #include "cm_tkns.h"       /* common tokens */
46 #include "cm_lte.h"        /* common tokens */
47 #include "rgu.h"           /* RGU defines */
48 #include "tfu.h"           /* RGU defines */
49 #include "lrg.h"           /* layer management defines for LTE-MAC */
50 #include "crg.h"           /* CRG interface includes */
51 #include "rg_sch_inf.h"    /* SCH interface includes */
52 #include "rg_prg.h"        /* PRG interface includes */
53 #include "rg_env.h"        /* customisable defines and macros for LTE-MAC */
54 #include "rg.h"            /* defines and macros for MAC */
55
56
57 /* header/extern include files (.x) */
58 #include "gen.x"           /* general layer typedefs */
59 #include "ssi.x"           /* system services typedefs */
60 #include "cm5.x"           /* common timers */
61 #include "cm_hash.x"       /* common hash list */
62 #include "cm_lib.x"        /* common library */
63 #include "cm_llist.x"      /* common linked list */
64 #include "cm_mblk.x"       /* memory management */
65 #include "cm_tkns.x"       /* common tokens */
66 #include "cm_lte.x"        /* common tokens */
67 #include "rgu.x"           /* RGU types */
68 #include "tfu.x"           /* RGU types */
69 #include "lrg.x"           /* layer management typedefs for MAC */
70 #include "crg.x"           /* CRG interface typedes */
71 #include "rg_sch_inf.x"    /* SCH interface typedefs */
72 #include "rg_prg.x"        /*PRG interface includes*/
73 #include "rg.x"            /* typedefs for MAC */
74
75
76 /**
77  * @brief Task Activation callback function Entity SM. 
78  *
79  * @details
80  *
81  *     Function : rgHdlSMEvents
82  *     
83  *     Process Messages received from Entity SM
84  *     
85  *  @param[in]  Pst     *pst, Post structure of the primitive.     
86  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
87  *  @param[in]  Reason reason.
88  *  @return  void
89  **/
90 #ifdef ANSI
91 PRIVATE INLINE void rgHdlSMEvents
92 (
93 Pst     *pst,                       /* post structure       */
94 Buffer  *mBuf                       /* message buffer       */
95 )
96 #else
97 PRIVATE INLINE void rgHdlSMEvents(pst, mBuf)
98 Pst     *pst;                       /* post structure       */
99 Buffer  *mBuf;                      /* message buffer       */
100 #endif
101 {
102    TRC2(rgHdlSMEvents)
103
104    switch(pst->event)
105    {
106 #ifdef LCRGMILRG
107       case EVTLRGCFGREQ:
108          /* Process a config. request */
109          cmUnpkLrgCfgReq(RgMiLrgCfgReq, pst, mBuf);
110          break;
111       case EVTLRGCNTRLREQ:
112          /* Process a control request */
113          cmUnpkLrgCntrlReq(RgMiLrgCntrlReq, pst, mBuf);
114          break;
115       case EVTLRGSSTAREQ:
116          /* Process a status request  */
117          cmUnpkLrgStaReq(RgMiLrgStaReq, pst, mBuf);
118          break;
119       case EVTLRGSTSREQ:
120          /* Process a statistics request */
121          cmUnpkLrgStsReq(RgMiLrgStsReq, pst, mBuf);
122          break;
123 #endif /* LCRGMILRG */
124       default:
125          RG_FREE_MSG(mBuf);
126          break;
127    }
128 }
129
130
131 /**
132  * @brief Task Activation callback function Entity NH. 
133  *
134  * @details
135  *
136  *     Function : rgHdlNHEvents
137  *     
138  *     Process Messages received from Entity NH
139  *     
140  *  @param[in]  Pst     *pst, Post structure of the primitive.     
141  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
142  *  @param[in]  Reason reason.
143  *  @return  void
144  **/
145 #ifdef ANSI
146 PRIVATE INLINE void rgHdlNHEvents
147 (
148 Pst     *pst,                       /* post structure       */
149 Buffer  *mBuf                       /* message buffer       */
150 )
151 #else
152 PRIVATE INLINE void rgHdlNHEvents(pst, mBuf)
153 Pst     *pst;                       /* post structure       */
154 Buffer  *mBuf;                      /* message buffer       */
155 #endif
156 {
157    TRC2(rgHdlNHEvents)
158
159    switch(pst->event)
160    {
161 #ifdef LCRGUICRG
162       case EVTCRGBNDREQ:
163          cmUnpkCrgBndReq(RgUiCrgBndReq, pst, mBuf);
164          break;
165       case EVTCRGUBNDREQ:
166          cmUnpkCrgUbndReq(RgUiCrgUbndReq, pst, mBuf);
167          break;
168       case EVTCRGCFGREQ:
169          cmUnpkCrgCfgReq(RgUiCrgCfgReq, pst, mBuf);
170          break;
171 #endif            
172       default:
173          RG_FREE_MSG(mBuf);
174          break;
175    }
176 }
177
178 /**
179  * @brief Task Activation callback function Entity KW. 
180  *
181  * @details
182  *
183  *     Function : rgHdlKWEvents
184  *     
185  *     Process Messages received from Entity KW
186  *     
187  *  @param[in]  Pst     *pst, Post structure of the primitive.     
188  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
189  *  @param[in]  Reason reason.
190  *  @return  void
191  **/
192 #ifdef ANSI
193 PRIVATE INLINE void rgHdlKWEvents
194 (
195 Pst     *pst,                       /* post structure       */
196 Buffer  *mBuf                       /* message buffer       */
197 )
198 #else
199 PRIVATE INLINE void rgHdlKWEvents(pst, mBuf)
200 Pst     *pst;                       /* post structure       */
201 Buffer  *mBuf;                      /* message buffer       */
202 #endif
203 {
204    TRC2(rgHdlKWEvents)
205
206    switch(pst->event)
207    {
208 #ifdef LCRGUIRGU
209       case EVTRGUBNDREQ:
210          cmUnpkRguBndReq(RgUiRguBndReq, pst, mBuf);
211          break;
212       case EVTRGUUBNDREQ:
213          cmUnpkRguUbndReq(RgUiRguUbndReq, pst, mBuf);
214          break;
215       case EVTRGUCDATREQ:
216          cmUnpkRguCDatReq(RgUiRguCDatReq, pst, mBuf);
217          break;
218       case EVTRGUDDATREQ:
219          cmUnpkRguDDatReq(RgUiRguDDatReq, pst, mBuf);
220          break;
221       case EVTRGUCSTARSP:
222          cmUnpkRguCStaRsp(RgUiRguCStaRsp, pst, mBuf);
223          break;
224       case EVTRGUDSTARSP:
225          cmUnpkRguDStaRsp(RgUiRguDStaRsp, pst, mBuf);
226          break;
227 #ifdef LTE_L2_MEAS
228
229       case EVTRGUL2MULTHRPMEASREQ:
230          cmUnpkRguL2MUlThrpMeasReq(RgUiRguL2MUlThrpMeasReq, pst,mBuf);
231          break;
232
233 #endif
234 #endif            
235       default:
236          RG_FREE_MSG(mBuf);
237          break;
238    }
239 }
240
241 /**
242  * @brief Task Activation callback function Entity TF. 
243  *
244  * @details
245  *
246  *     Function : rgHdlTFEvents
247  *     
248  *     Process Messages received from Entity TF
249  *     
250  *  @param[in]  Pst     *pst, Post structure of the primitive.     
251  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
252  *  @param[in]  Reason reason.
253  *  @return  void
254  **/
255 #ifdef ANSI
256 PRIVATE INLINE void rgHdlTFEvents
257 (
258 Pst     *pst,                       /* post structure       */
259 Buffer  *mBuf                       /* message buffer       */
260 )
261 #else
262 PRIVATE INLINE void rgHdlTFEvents(pst, mBuf)
263 Pst     *pst;                       /* post structure       */
264 Buffer  *mBuf;                      /* message buffer       */
265 #endif
266 {
267    TRC2(rgHdlTFEvents)
268
269    switch(pst->event)
270    {
271 #if  (defined(LCRGLITFU) || defined(LWLCRGLITFU))
272       case EVTTFUBNDCFM:
273          cmUnpkTfuBndCfm(RgLiTfuBndCfm, pst, mBuf);
274          break;
275       case EVTTFUDATIND:
276          cmUnpkTfuDatInd(RgLiTfuDatInd, pst, mBuf);
277          break;
278       case EVTTFUTTIIND:
279          cmUnpkTfuTtiInd(RgLiTfuTtiInd, pst, mBuf);
280          break;
281 #if defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
282       case EVTTFUNONRTIND:
283          cmUnpkTfuNonRtInd(RgLiTfuNonRtInd, pst, mBuf);
284          break;
285 #endif
286 #endif            
287       default:
288          RG_FREE_MSG(mBuf);
289          break;
290    }
291 }
292
293
294 /**
295  * @brief Task Activation callback function Entity RG SCH. 
296  *
297  * @details
298  *
299  *     Function : rgHdlRGEvents
300  *     
301  *     Process Messages received from Entity RG SCH
302  *     
303  *  @param[in]  Pst     *pst, Post structure of the primitive.     
304  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
305  *  @param[in]  Reason reason.
306  *  @return  void
307  **/
308 #ifdef ANSI
309 PRIVATE INLINE void rgHdlRGEvents
310 (
311 Pst     *pst,                       /* post structure       */
312 Buffer  *mBuf                       /* message buffer       */
313 )
314 #else
315 PRIVATE INLINE void rgHdlRGEvents(pst, mBuf)
316 Pst     *pst;                       /* post structure       */
317 Buffer  *mBuf;                      /* message buffer       */
318 #endif
319 {
320    TRC2(rgHdlRGEvents)
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 PUBLIC S16 rgActvTsk
436 (
437 Pst     *pst,                       /* post structure       */
438 Buffer  *mBuf                       /* message buffer       */
439 )
440 #else
441 PUBLIC S16 rgActvTsk(pst, mBuf)
442 Pst     *pst;                       /* post structure       */
443 Buffer  *mBuf;                      /* message buffer       */
444 #endif
445 {
446    TRC2(rgActvTsk)
447
448    switch(pst->srcEnt)
449    {
450       /* The originator of this message is the stack manager,
451        * unpack and go to the respective primitive processing function */
452       case ENTSM:
453           rgHdlSMEvents(pst, mBuf);
454            break;
455       case ENTNH:
456           rgHdlNHEvents(pst, mBuf);
457           break;
458       case ENTKW:
459           rgHdlKWEvents(pst, mBuf);
460           break;
461       case ENTTF:
462           rgHdlTFEvents(pst, mBuf);
463           break;
464       case ENTRG: /* When scheduler instance sends msg to MAC */
465           rgHdlRGEvents(pst, mBuf);
466           break;
467        default:
468           RG_FREE_MSG(mBuf);
469           break;
470    }
471    SExitTsk();
472    RETVALUE(ROK);
473 }/* end of rgActvTsk */
474
475 \f
476 /**********************************************************************
477  
478          End of file
479 **********************************************************************/