[Epic-ID: ODUHIGH-461][Task-ID: ODUHIGH-468]Unused files and functions removed/disabled
[o-du/l2.git] / src / 5gnrmac / mac_msg_router.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:     mac_msg_router.c
28   
29 **********************************************************************/
30
31 /** @file mac_msg_router.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 EVTLRGSTSREQ:
94          /* Process a statistics request */
95          cmUnpkLrgStsReq(RgMiLrgStsReq, pst, mBuf);
96          break;
97 #endif /* LCRGMILRG */
98       case EVENT_MAC_CELL_CONFIG_REQ:
99          {
100             /* Process MAC cell config */
101             unpackDuMacCellCfg(MacProcCellCfgReq, pst, mBuf);
102             break;
103          }
104       case EVENT_MAC_CELL_START:
105          {
106             /* Process MAC cell start request */
107             unpackMacCellStart(MacProcCellStart, pst, mBuf);
108             break;
109          }
110       case EVENT_MAC_CELL_STOP:
111          {
112             /* Process MAC cell stop request */
113             unpackMacCellStop(MacProcCellStop, pst, mBuf);
114             break;
115          }
116       case EVENT_MAC_DL_CCCH_IND:
117          {
118             /* Process DL CCCH Ind */
119             unpackMacDlCcchInd(MacProcDlCcchInd, pst, mBuf);
120             break;
121          }
122       case EVENT_MAC_UE_CREATE_REQ:
123          {
124             /* Process Ue Create Request */
125             unpackMacUeCreateReq(MacProcUeCreateReq, pst, mBuf);
126             break;
127          }
128       case EVENT_MAC_UE_RECONFIG_REQ:
129          {
130             /* Process Ue Reconfig Request */
131             unpackMacUeReconfigReq(MacProcUeReconfigReq, pst, mBuf);
132             break;
133          }
134       case EVENT_MAC_UE_DELETE_REQ:
135          {
136             /* Process UE Delete Request */  
137             unpackMacUeDeleteReq(MacProcUeDeleteReq, pst, mBuf);
138             break;
139          }
140       case EVENT_MAC_CELL_DELETE_REQ:
141          {
142             /* Process Cell Delete Request */
143             unpackMacCellDeleteReq(MacProcCellDeleteReq, pst, mBuf);
144             break;
145          }
146       case EVENT_MAC_SLICE_CFG_REQ:
147          {
148             /* Process Slice Configuration Request */
149             unpackMacSliceCfgReq(MacProcSliceCfgReq, pst, mBuf);
150             break;
151          }
152       case EVENT_MAC_SLICE_RECFG_REQ:
153          {
154             /* Process Slice Reconfiguration Request */
155             unpackMacSliceRecfgReq(MacProcSliceRecfgReq, pst, mBuf);
156             break;
157          }
158       case EVENT_MAC_RACH_RESOURCE_REQ:
159          {
160             /* Process Rach Resource Request */
161             unpackMacRachRsrcReq(MacProcRachRsrcReq, pst, mBuf);
162             break;
163          }
164       case EVENT_MAC_RACH_RESOURCE_REL:
165          {
166             /* Process Rach Resource Release */
167             unpackMacRachRsrcRel(MacProcRachRsrcRel, pst, mBuf);
168             break;
169          }
170       case EVENT_MAC_DL_PCCH_IND:
171          {
172             /* Process Pcch indication */
173             unpackMacDlPcchInd(MacProcDlPcchInd, pst, mBuf);
174             break;
175          }
176
177       default:
178          RG_FREE_MSG(mBuf);
179          break;
180    }
181 }
182
183
184 /**
185  * @brief Task Activation callback function Entity NH. 
186  *
187  * @details
188  *
189  *     Function : rgHdlNHEvents
190  *     
191  *     Process Messages received from Entity NH
192  *     
193  *  @param[in]  Pst     *pst, Post structure of the primitive.     
194  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
195  *  @param[in]  Reason reason.
196  *  @return  void
197  **/
198 static inline void rgHdlNHEvents
199 (
200 Pst     *pst,                       /* post structure       */
201 Buffer  *mBuf                       /* message buffer       */
202 )
203 {
204    switch(pst->event)
205    {
206 #ifdef LCRGUICRG
207       case EVTCRGBNDREQ:
208          cmUnpkCrgBndReq(RgUiCrgBndReq, pst, mBuf);
209          break;
210       case EVTCRGUBNDREQ:
211          cmUnpkCrgUbndReq(RgUiCrgUbndReq, pst, mBuf);
212          break;
213 #endif            
214       default:
215          RG_FREE_MSG(mBuf);
216          break;
217    }
218 }
219
220 /**
221  * @brief Task Activation callback function Entity KW. 
222  *
223  * @details
224  *
225  *     Function : rgHdlKWEvents
226  *     
227  *     Process Messages received from Entity KW
228  *     
229  *  @param[in]  Pst     *pst, Post structure of the primitive.     
230  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
231  *  @param[in]  Reason reason.
232  *  @return  void
233  **/
234 static inline void rgHdlKWEvents
235 (
236 Pst     *pst,                       /* post structure       */
237 Buffer  *mBuf                       /* message buffer       */
238 )
239 {
240    switch(pst->event)
241    {
242 #ifdef LCRGUIRGU
243       case EVTRGUBNDREQ:
244          cmUnpkRguBndReq(RgUiRguBndReq, pst, mBuf);
245          break;
246       case EVTRGUUBNDREQ:
247          cmUnpkRguUbndReq(RgUiRguUbndReq, pst, mBuf);
248          break;
249       case EVENT_DL_DATA_TO_MAC:
250          unpackRlcDlData(MacProcRlcDlData, pst, mBuf);
251          break;
252       case EVENT_BO_STATUS_TO_MAC:
253          unpackRlcBoStatus(MacProcRlcBoStatus, pst, mBuf);
254          break;
255 #ifdef LTE_L2_MEAS
256
257       case EVTRGUL2MULTHRPMEASREQ:
258          cmUnpkRguL2MUlThrpMeasReq(RgUiRguL2MUlThrpMeasReq, pst,mBuf);
259          break;
260
261 #endif
262 #endif            
263       default:
264          RG_FREE_MSG(mBuf);
265          break;
266    }
267 }
268
269 /**
270  * @brief Task Activation callback function Entity TF. 
271  *
272  * @details
273  *
274  *     Function : rgHdlTFEvents
275  *     
276  *     Process Messages received from Entity TF
277  *     
278  *  @param[in]  Pst     *pst, Post structure of the primitive.     
279  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
280  *  @param[in]  Reason reason.
281  *  @return  void
282  **/
283 static inline void rgHdlTFEvents
284 (
285 Pst     *pst,                       /* post structure       */
286 Buffer  *mBuf                       /* message buffer       */
287 )
288 {
289    switch(pst->event)
290    {
291       case EVENT_SLOT_IND_TO_MAC:
292          unpackSlotInd(fapiMacSlotInd, pst, mBuf);
293          break;
294       case EVENT_STOP_IND_TO_MAC:
295          unpackStopInd(fapiMacStopInd, pst, mBuf);
296          break;
297       case EVENT_RACH_IND_TO_MAC:
298          unpackRachInd(fapiMacRachInd, pst, mBuf);
299          break;
300       case EVENT_CRC_IND_TO_MAC:
301          unpackCrcInd(fapiMacCrcInd, pst, mBuf);
302          break;
303       case EVENT_RX_DATA_IND_TO_MAC:
304          unpackRxDataInd(fapiMacRxDataInd, pst, mBuf);
305          break;
306       case EVENT_UCI_IND_TO_MAC:
307          unpackUciInd(FapiMacUciInd, pst, mBuf);
308          break;
309       default:
310          RG_FREE_MSG(mBuf);
311          break;
312    }
313 }
314
315
316 /**
317  * @brief Task Activation callback function Entity RG SCH. 
318  *
319  * @details
320  *
321  *     Function : rgHdlRGEvents
322  *     
323  *     Process Messages received from Entity RG SCH
324  *     
325  *  @param[in]  Pst     *pst, Post structure of the primitive.     
326  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
327  *  @param[in]  Reason reason.
328  *  @return  void
329  **/
330 static inline void rgHdlRGEvents
331 (
332 Pst     *pst,                       /* post structure       */
333 Buffer  *mBuf                       /* message buffer       */
334 )
335 {
336    switch(pst->event)
337    {
338 #ifdef LCRG
339       case EVTINFCELLREGREQ:
340          cmUnpkSchMacCellRegReq(RgSchMacCellRegReq, pst, mBuf);
341          break;
342       case EVTINFSFALLOCREQ:
343          cmUnpkSchMacSfAllocReq(RgSchMacSfAllocReq, pst, mBuf);
344          break;
345       case EVTINFRLSHQREQ:
346          cmUnpkSchMacRlsHqReq(RgSchMacRlsHqReq, pst, mBuf);
347          break;
348       case EVTINFHQENTRESET:
349          cmUnpkSchMacRstHqEntReq(RgSchMacRstHqEntReq, pst, mBuf);
350          break;
351       case EVTINFRLSRNTIREQ:
352          cmUnpkSchMacRlsRntiReq(RgSchMacRlsRntiReq, pst, mBuf);
353          break;
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 #endif /* LCRG */
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 #ifdef CALL_FLOW_DEBUG_LOG
415 /**
416 * @brief Function prints src, dest, msg infor about all the msgs that received.
417 *
418 * @details
419 *
420 *     Function : callFlowRgActvTsk 
421 *
422 *     Function prints src, dest, msg infor about all the msgs that received
423 *
424 *  @param[in]  Pst     *pst, Post structure of the primitive.
425 *
426 *  @return  void
427 **/
428
429 void callFlowRgActvTsk(Pst *pst)
430 {
431    char sourceTask[50];
432    char destTask[50]="ENTMAC";
433    char message[100];
434
435    switch(pst->srcEnt)
436    {
437       case ENTDUAPP:
438          {
439             strcpy(sourceTask,"ENTDUAPP");
440             switch(pst->event)
441             {
442 #ifdef LCRGMILRG
443                case EVTLRGCFGREQ:
444                   strcpy(message,"EVTLRGCFGREQ");
445                   break;
446                case EVTMACSCHGENCFGREQ:
447                   strcpy(message,"EVTMACSCHGENCFGREQ");
448                   break;
449 #endif /* LCRGMILRG */
450                case EVENT_MAC_CELL_CONFIG_REQ:
451                   strcpy(message,"EVENT_MAC_CELL_CONFIG_REQ");
452                   break;
453                case EVENT_MAC_CELL_START:
454                   strcpy(message,"EVENT_MAC_CELL_START");
455                   break;
456                case EVENT_MAC_CELL_STOP:
457                   strcpy(message,"EVENT_MAC_CELL_STOP");
458                   break;
459                case EVENT_MAC_DL_CCCH_IND:
460                   strcpy(message,"EVENT_MAC_DL_CCCH_IND");
461                   break;
462                case EVENT_MAC_UE_CREATE_REQ:
463                   strcpy(message,"EVENT_MAC_UE_CREATE_REQ");
464                   break;
465                case EVENT_MAC_UE_RECONFIG_REQ:
466                   strcpy(message,"EVENT_MAC_UE_RECONFIG_REQ");
467                   break;
468                case EVENT_MAC_UE_DELETE_REQ:
469                   strcpy(message,"EVENT_MAC_UE_DELETE_REQ");
470                   break;
471                case EVENT_MAC_CELL_DELETE_REQ:
472                   strcpy(message,"EVENT_MAC_CELL_DELETE_REQ");
473                   break;
474                case EVENT_MAC_SLICE_CFG_REQ:
475                   strcpy(message,"EVENT_MAC_SLICE_CFG_REQ");
476                   break;
477                case EVENT_MAC_SLICE_RECFG_REQ:
478                   strcpy(message,"EVENT_MAC_SLICE_RECFG_REQ");
479                   break;
480                default:
481                   strcpy(message,"Invalid Event");
482                   break;
483             }
484             break;
485          }
486       case ENTRLC:
487          { 
488             strcpy(sourceTask,"ENTRLC");
489             switch(pst->event)
490             {
491 #ifdef LCRGUIRGU
492                case EVTRGUBNDREQ:
493                   strcpy(message,"EVTRGUBNDREQ");
494                   break;
495                case EVTRGUUBNDREQ:
496                   strcpy(message,"EVTRGUUBNDREQ");
497                   break;
498                case EVENT_DL_DATA_TO_MAC:
499                   strcpy(message,"EVENT_DL_DATA_TO_MAC");
500                   break;
501                case EVENT_BO_STATUS_TO_MAC:
502                   strcpy(message,"EVENT_BO_STATUS_TO_MAC");
503                   break;
504 #endif
505                default:
506                   strcpy(message,"Invalid Event");
507                   break;
508             }
509
510             break;
511          }
512       case ENTLWRMAC:
513          {
514             strcpy(sourceTask,"ENTLWRMAC");
515             switch(pst->event)
516             {
517                case EVENT_SLOT_IND_TO_MAC:
518                   strcpy(message,"EVENT_SLOT_IND_TO_MAC");
519                   break;
520                case EVENT_STOP_IND_TO_MAC:
521                   strcpy(message,"EVENT_STOP_IND_TO_MAC");
522                   break;
523                case EVENT_RACH_IND_TO_MAC:
524                   strcpy(message,"EVENT_RACH_IND_TO_MAC");
525                   break;
526                case EVENT_CRC_IND_TO_MAC:
527                   strcpy(message,"EVENT_CRC_IND_TO_MAC");
528                   break;
529                case EVENT_RX_DATA_IND_TO_MAC:
530                   strcpy(message,"EVENT_RX_DATA_IND_TO_MAC");
531                   break;
532                case EVENT_UCI_IND_TO_MAC:
533                   strcpy(message,"EVENT_UCI_IND_TO_MAC");
534                   break;
535                default:
536                   strcpy(message,"Invalid Event");
537                   break;
538             }
539
540             break;
541          }
542       case ENTMAC: /* When scheduler instance sends msg to MAC */
543          {
544             strcpy(sourceTask,"ENTMAC");
545             switch(pst->event)
546             {
547 #ifdef LCRG
548                case EVTINFCELLREGREQ:
549                   strcpy(message,"EVTINFCELLREGREQ");
550                   break;
551                case EVTINFSFALLOCREQ:
552                   strcpy(message,"EVTINFSFALLOCREQ");
553                   break;
554                case EVTINFRLSHQREQ:
555                   strcpy(message,"EVTINFRLSHQREQ");
556                   break;
557                case EVTINFHQENTRESET:
558                   strcpy(message,"EVTINFHQENTRESET");
559                   break;
560                case EVTINFRLSRNTIREQ:
561                   strcpy(message,"EVTINFRLSRNTIREQ");
562                   break;
563 #endif            
564 #if defined(LTE_ADV) && defined(LCPRG)
565                case EVTPRGUESCELLCFGREQ:
566                   strcpy(message,"EVTPRGUESCELLCFGREQ");
567                   break;
568                case EVTPRGUESCELLCFGCFM:
569                   strcpy(message,"EVTPRGUESCELLCFGCFM");
570                   break;
571                case EVTPRGUESCELLLCHMODCFM:
572                   strcpy(message,"EVTPRGUESCELLLCHMODCFM");
573                   break;
574                case EVTPRGUESCELLLCHDELCFMDEL:
575                   strcpy(message,"EVTPRGUESCELLLCHDELCFMDEL");
576                   break;
577                case EVTPRGUESCELLLCHADDCFM:
578                   strcpy(message,"EVTPRGUESCELLLCHADDCFM");
579                   break;
580                case EVTPRGUESCELLDELREQ:
581                   strcpy(message,"EVTPRGUESCELLDELREQ");
582                   break;
583                case EVTPRGUESCELLLCHMODREQ:
584                   strcpy(message,"EVTPRGUESCELLLCHMODREQ");
585                   break;
586                case EVTPRGUESCELLLCHDELREQ:
587                   strcpy(message,"EVTPRGUESCELLLCHDELREQ");
588                   break;
589                case EVTPRGUESCELLLCHADDREQ:
590                   strcpy(message,"EVTPRGUESCELLLCHADDREQ");
591                   break;
592
593 #endif
594                default:
595                   strcpy(message,"Invalid Event");
596                   break;
597             }
598             break;
599          }
600
601       default:
602          {
603             strcpy(sourceTask,"Invalid Source Entity Id");
604             break;
605          }
606    }
607    DU_LOG("\nCall Flow: %s -> %s : %s\n", sourceTask, destTask, message);
608 }
609 #endif
610
611 \f
612 /**
613  * @brief Task Activation callback function. 
614  *
615  * @details
616  *
617  *     Function : rgActvTsk
618  *     
619  *     Primitives invoked by MAC's users/providers through
620  *     a loosely coupled interface arrive here by means of 
621  *     SSI's message handling. This API is registered with
622  *     SSI during the Task Registration of MAC.
623  *     
624  *  @param[in]  Pst     *pst, Post structure of the primitive.     
625  *  @param[in]  Buffer *mBuf, Packed primitive parameters in the buffer.
626  *  @param[in]  Reason reason.
627  *  @return  S16
628  *      -# ROK
629  **/
630 S16 rgActvTsk
631 (
632 Pst     *pst,                       /* post structure       */
633 Buffer  *mBuf                       /* message buffer       */
634 )
635 {
636
637 #ifdef CALL_FLOW_DEBUG_LOG
638    callFlowRgActvTsk(pst);
639 #endif
640
641    switch(pst->srcEnt)
642    {
643       /* The originator of this message is the stack manager,
644        * unpack and go to the respective primitive processing function */
645       case ENTDUAPP:
646           rgHdlSMEvents(pst, mBuf);
647            break;
648       case ENTNH:
649           rgHdlNHEvents(pst, mBuf);
650           break;
651       case ENTRLC:
652           rgHdlKWEvents(pst, mBuf);
653           break;
654       case ENTLWRMAC:
655           rgHdlTFEvents(pst, mBuf);
656           break;
657       case ENTMAC: /* When scheduler instance sends msg to MAC */
658           rgHdlRGEvents(pst, mBuf);
659           break;
660        default:
661           RG_FREE_MSG(mBuf);
662           break;
663    }
664    ODU_EXIT_TASK();
665    return ROK;
666 }/* end of rgActvTsk */
667
668 \f
669 /**********************************************************************
670  
671          End of file
672 **********************************************************************/