RLC-MAC Interface APIs and Memory configuration Changes
[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 "rgr.h"           /* layer management defines for LTE-MAC */
51 #include "crg.h"           /* CRG interface includes */
52 #include "rg_sch_inf.h"    /* SCH interface includes */
53 #include "rg_prg.h"        /* PRG interface includes */
54 #include "rg_env.h"        /* customisable defines and macros for LTE-MAC */
55 #include "rg.h"            /* defines and macros for MAC */
56 #include "rgr.h"            /* defines and macros for SCH */
57
58
59 /* header/extern include files (.x) */
60 #include "gen.x"           /* general layer typedefs */
61 #include "ssi.x"           /* system services typedefs */
62 #include "cm5.x"           /* common timers */
63 #include "cm_hash.x"       /* common hash list */
64 #include "cm_lib.x"        /* common library */
65 #include "cm_llist.x"      /* common linked list */
66 #include "cm_mblk.x"       /* memory management */
67 #include "cm_tkns.x"       /* common tokens */
68 #include "cm_lte.x"        /* common tokens */
69 #include "rgu.x"           /* RGU types */
70 #include "tfu.x"           /* RGU types */
71 #include "lrg.x"           /* layer management typedefs for MAC */
72 #include "rgr.x"           /* layer management typedefs for MAC */
73 #include "crg.x"           /* CRG interface typedes */
74 #include "rg_sch_inf.x"    /* SCH interface typedefs */
75 #include "rg_prg.x"        /*PRG interface includes*/
76 #include "rg.x"            /* typedefs for MAC */
77
78
79 /**
80  * @brief Task Activation callback function Entity SM. 
81  *
82  * @details
83  *
84  *     Function : rgHdlSMEvents
85  *     
86  *     Process Messages received from Entity SM
87  *     
88  *  @param[in]  Pst     *pst, Post structure of the primitive.     
89  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
90  *  @param[in]  Reason reason.
91  *  @return  void
92  **/
93 #ifdef ANSI
94 PRIVATE INLINE void rgHdlSMEvents
95 (
96 Pst     *pst,                       /* post structure       */
97 Buffer  *mBuf                       /* message buffer       */
98 )
99 #else
100 PRIVATE INLINE void rgHdlSMEvents(pst, mBuf)
101 Pst     *pst;                       /* post structure       */
102 Buffer  *mBuf;                      /* message buffer       */
103 #endif
104 {
105    TRC2(rgHdlSMEvents)
106
107    switch(pst->event)
108    {
109 #ifdef LCRGMILRG
110       case EVTLRGCFGREQ:
111          /* Process a config. request */
112          cmUnpkLrgCfgReq(RgMiLrgCfgReq, pst, mBuf);
113          break;
114       case EVTMACSCHGENCFGREQ:
115          /* Process a config. request */
116          cmUnpkLrgSchCfgReq(MacSchGenCfgReq, pst, mBuf);
117          break;
118       case EVTMACSCHCFGREQ: 
119          cmUnpkRgrCfgReq(MacSchCfgReq, pst, mBuf);
120          break;
121       case EVTLRGCNTRLREQ:
122          /* Process a control request */
123          cmUnpkLrgCntrlReq(RgMiLrgCntrlReq, pst, mBuf);
124          break;
125       case EVTLRGSSTAREQ:
126          /* Process a status request  */
127          cmUnpkLrgStaReq(RgMiLrgStaReq, pst, mBuf);
128          break;
129       case EVTLRGSTSREQ:
130          /* Process a statistics request */
131          cmUnpkLrgStsReq(RgMiLrgStsReq, pst, mBuf);
132          break;
133 #endif /* LCRGMILRG */
134       default:
135          RG_FREE_MSG(mBuf);
136          break;
137    }
138 }
139
140
141 /**
142  * @brief Task Activation callback function Entity NH. 
143  *
144  * @details
145  *
146  *     Function : rgHdlNHEvents
147  *     
148  *     Process Messages received from Entity NH
149  *     
150  *  @param[in]  Pst     *pst, Post structure of the primitive.     
151  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
152  *  @param[in]  Reason reason.
153  *  @return  void
154  **/
155 #ifdef ANSI
156 PRIVATE INLINE void rgHdlNHEvents
157 (
158 Pst     *pst,                       /* post structure       */
159 Buffer  *mBuf                       /* message buffer       */
160 )
161 #else
162 PRIVATE INLINE void rgHdlNHEvents(pst, mBuf)
163 Pst     *pst;                       /* post structure       */
164 Buffer  *mBuf;                      /* message buffer       */
165 #endif
166 {
167    TRC2(rgHdlNHEvents)
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 PRIVATE INLINE void rgHdlKWEvents
204 (
205 Pst     *pst,                       /* post structure       */
206 Buffer  *mBuf                       /* message buffer       */
207 )
208 #else
209 PRIVATE INLINE void rgHdlKWEvents(pst, mBuf)
210 Pst     *pst;                       /* post structure       */
211 Buffer  *mBuf;                      /* message buffer       */
212 #endif
213 {
214    TRC2(rgHdlKWEvents)
215
216    switch(pst->event)
217    {
218 #ifdef LCRGUIRGU
219       case EVTRGUBNDREQ:
220          cmUnpkRguBndReq(RgUiRguBndReq, pst, mBuf);
221          break;
222       case EVTRGUUBNDREQ:
223          cmUnpkRguUbndReq(RgUiRguUbndReq, pst, mBuf);
224          break;
225       case EVTRLCDLDAT:
226          unpackSendDlData(RgUiRguDDatReq, pst, mBuf);
227          break;
228       case EVTRLCBOSTA:
229          unpackSendBOStatus(RgUiRguDStaRsp, pst, mBuf);
230          break;
231 #ifdef LTE_L2_MEAS
232
233       case EVTRGUL2MULTHRPMEASREQ:
234          cmUnpkRguL2MUlThrpMeasReq(RgUiRguL2MUlThrpMeasReq, pst,mBuf);
235          break;
236
237 #endif
238 #endif            
239       default:
240          RG_FREE_MSG(mBuf);
241          break;
242    }
243 }
244
245 /**
246  * @brief Task Activation callback function Entity TF. 
247  *
248  * @details
249  *
250  *     Function : rgHdlTFEvents
251  *     
252  *     Process Messages received from Entity TF
253  *     
254  *  @param[in]  Pst     *pst, Post structure of the primitive.     
255  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
256  *  @param[in]  Reason reason.
257  *  @return  void
258  **/
259 #ifdef ANSI
260 PRIVATE INLINE void rgHdlTFEvents
261 (
262 Pst     *pst,                       /* post structure       */
263 Buffer  *mBuf                       /* message buffer       */
264 )
265 #else
266 PRIVATE INLINE void rgHdlTFEvents(pst, mBuf)
267 Pst     *pst;                       /* post structure       */
268 Buffer  *mBuf;                      /* message buffer       */
269 #endif
270 {
271    TRC2(rgHdlTFEvents)
272
273    switch(pst->event)
274    {
275 #if  (defined(LCRGLITFU) || defined(LWLCRGLITFU))
276       case EVTTFUBNDCFM:
277          cmUnpkTfuBndCfm(RgLiTfuBndCfm, pst, mBuf);
278          break;
279       case EVTTFUDATIND:
280          cmUnpkTfuDatInd(RgLiTfuDatInd, pst, mBuf);
281          break;
282       case EVTTFUTTIIND:
283          cmUnpkTfuTtiInd(RgLiTfuTtiInd, pst, mBuf);
284          break;
285 #if defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
286       case EVTTFUNONRTIND:
287          cmUnpkTfuNonRtInd(RgLiTfuNonRtInd, pst, mBuf);
288          break;
289 #endif
290 #endif            
291       default:
292          RG_FREE_MSG(mBuf);
293          break;
294    }
295 }
296
297
298 /**
299  * @brief Task Activation callback function Entity RG SCH. 
300  *
301  * @details
302  *
303  *     Function : rgHdlRGEvents
304  *     
305  *     Process Messages received from Entity RG SCH
306  *     
307  *  @param[in]  Pst     *pst, Post structure of the primitive.     
308  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
309  *  @param[in]  Reason reason.
310  *  @return  void
311  **/
312 #ifdef ANSI
313 PRIVATE INLINE void rgHdlRGEvents
314 (
315 Pst     *pst,                       /* post structure       */
316 Buffer  *mBuf                       /* message buffer       */
317 )
318 #else
319 PRIVATE INLINE void rgHdlRGEvents(pst, mBuf)
320 Pst     *pst;                       /* post structure       */
321 Buffer  *mBuf;                      /* message buffer       */
322 #endif
323 {
324    TRC2(rgHdlRGEvents)
325
326    switch(pst->event)
327    {
328 #ifdef LCRG
329       case EVTINFCELLREGREQ:
330          cmUnpkSchMacCellRegReq(RgSchMacCellRegReq, pst, mBuf);
331          break;
332       case EVTINFSFALLOCREQ:
333          cmUnpkSchMacSfAllocReq(RgSchMacSfAllocReq, pst, mBuf);
334          break;
335       case EVTINFRLSHQREQ:
336          cmUnpkSchMacRlsHqReq(RgSchMacRlsHqReq, pst, mBuf);
337          break;
338       case EVTINFHQENTRESET:
339          cmUnpkSchMacRstHqEntReq(RgSchMacRstHqEntReq, pst, mBuf);
340          break;
341       case EVTINFRLSRNTIREQ:
342          cmUnpkSchMacRlsRntiReq(RgSchMacRlsRntiReq, pst, mBuf);
343          break;
344 #ifdef LTEMAC_SPS
345       case EVTINFSPSLCREG:
346          cmUnpkSchMacSpsLcRegReq(RgSchMacSpsLcRegReq, pst, mBuf);
347          break;
348       case EVTINFSPSLCDEREG:
349          cmUnpkSchMacSpsLcDeregReq(RgSchMacSpsLcDeregReq, pst, mBuf);
350          break;
351       case EVTINFSPSRESET:
352          cmUnpkSchMacUlSpsResetReq(RgSchMacUlSpsResetReq, pst, mBuf);
353          break;
354 #endif /* LTEMAC_SPS */
355 #ifdef LTE_L2_MEAS
356       case EVTINFL2MEASREQ:
357          cmUnpkSchMacL2MeasReq(RgSchMacL2MeasReq, pst, mBuf);
358          break;
359       case EVTINFL2MEASSENDREQ :
360          cmUnpkSchMacL2MeasSendReq(RgSchMacL2MeasSendReq, pst , mBuf);
361          break;
362       case EVTINFL2MEASSTOPREQ:
363          cmUnpkSchMacL2MeasStopReq(RgSchMacL2MeasStopReq, pst , mBuf);
364          break;
365 #endif/* LTE_L2_MEAS */
366       case EVTINFLCGREG:
367          cmUnpkSchMacLcgRegReq(RgSchMacLcgRegReq, pst, mBuf);
368          break;
369 #endif            
370 #if defined(LTE_ADV) && defined(LCPRG)
371       case EVTPRGUESCELLCFGREQ:
372       {
373          cmUnpkPrgPMacSMacUeSCellCfgReq(RgPrgPMacSMacUeSCellCfgReq, pst, mBuf);
374       }
375       break;
376       case EVTPRGUESCELLCFGCFM:
377       case EVTPRGUESCELLLCHMODCFM:
378       case EVTPRGUESCELLLCHDELCFMDEL:
379       case EVTPRGUESCELLLCHADDCFM:
380       {
381          cmUnpkPrgSMacPMacCfgCfm(RgPrgSMacPMacCfgCfm, pst, mBuf);
382       }
383       break;
384       case EVTPRGUESCELLDELREQ:
385       {
386          cmUnpkPrgPMacSMacUeSCellDelReq(RgPrgPMacSMacUeSCellDelReq, pst, mBuf);
387       }
388       break;
389       case EVTPRGUESCELLLCHMODREQ:
390       {
391          cmUnpkPrgPMacSMacUeSCellLchModReq(RgPrgPMacSMacUeSCellLchModReq, pst,
392                                            mBuf);
393       }
394       break;
395       case EVTPRGUESCELLLCHDELREQ:
396       {
397          cmUnpkPrgPMacSMacUeSCellLchDelReq(RgPrgPMacSMacUeSCellLchDelReq, pst,
398                                            mBuf);
399       }
400       break;
401       case EVTPRGUESCELLLCHADDREQ:
402       {
403          cmUnpkPrgPMacSMacUeSCellLchAddReq(RgPrgPMacSMacUeSCellLchAddReq, pst,
404                                            mBuf);
405       }
406       break;
407
408 #endif
409       default:
410       {
411          RG_FREE_MSG(mBuf);
412          break;
413       }
414
415    }
416 }
417
418
419 \f
420 /**
421  * @brief Task Activation callback function. 
422  *
423  * @details
424  *
425  *     Function : rgActvTsk
426  *     
427  *     Primitives invoked by MAC's users/providers through
428  *     a loosely coupled interface arrive here by means of 
429  *     SSI's message handling. This API is registered with
430  *     SSI during the Task Registration of MAC.
431  *     
432  *  @param[in]  Pst     *pst, Post structure of the primitive.     
433  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
434  *  @param[in]  Reason reason.
435  *  @return  S16
436  *      -# ROK
437  **/
438 #ifdef ANSI
439 PUBLIC S16 rgActvTsk
440 (
441 Pst     *pst,                       /* post structure       */
442 Buffer  *mBuf                       /* message buffer       */
443 )
444 #else
445 PUBLIC S16 rgActvTsk(pst, mBuf)
446 Pst     *pst;                       /* post structure       */
447 Buffer  *mBuf;                      /* message buffer       */
448 #endif
449 {
450    TRC2(rgActvTsk)
451
452    switch(pst->srcEnt)
453    {
454       /* The originator of this message is the stack manager,
455        * unpack and go to the respective primitive processing function */
456       case ENTDUAPP:
457           rgHdlSMEvents(pst, mBuf);
458            break;
459       case ENTNH:
460           rgHdlNHEvents(pst, mBuf);
461           break;
462       case ENTKW:
463           rgHdlKWEvents(pst, mBuf);
464           break;
465       case ENTTF:
466           rgHdlTFEvents(pst, mBuf);
467           break;
468       case ENTRG: /* When scheduler instance sends msg to MAC */
469           rgHdlRGEvents(pst, mBuf);
470           break;
471        default:
472           RG_FREE_MSG(mBuf);
473           break;
474    }
475    SExitTsk();
476    RETVALUE(ROK);
477 }/* end of rgActvTsk */
478
479 \f
480 /**********************************************************************
481  
482          End of file
483 **********************************************************************/