1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /************************************************************************
25 Desc: C source code SSI Interface Implementation
27 File: mac_msg_router.c
29 **********************************************************************/
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.
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 */
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 #include "mac_sch_interface.h"
63 #include "mac_ue_mgr.h"
64 #include "mac_harq_dl.h"
67 * @brief Task Activation callback function Entity DU APP.
71 * Function : MacHdlDuappEvents
73 * Process Messages received from Entity DU APP
75 * @param[in] Pst *pst, Post structure of the primitive.
76 * @param[in] Buffer *mBuf, Packed primitive parameters in the buffer.
77 * @param[in] Reason reason.
80 void MacHdlDuappEvents(Pst *pst, Buffer *mBuf)
86 /* Process a config. request */
87 cmUnpkLrgCfgReq(RgMiLrgCfgReq, pst, mBuf);
89 case EVTMACSCHGENCFGREQ:
90 /* Process a config. request */
91 cmUnpkLrgSchCfgReq(MacSchGenCfgReq, pst, mBuf);
94 /* Process a statistics request */
95 cmUnpkLrgStsReq(RgMiLrgStsReq, pst, mBuf);
97 #endif /* LCRGMILRG */
98 case EVENT_MAC_CELL_CONFIG_REQ:
100 /* Process MAC cell config */
101 unpackDuMacCellCfg(MacProcCellCfgReq, pst, mBuf);
104 case EVENT_MAC_CELL_START:
106 /* Process MAC cell start request */
107 unpackMacCellStart(MacProcCellStart, pst, mBuf);
110 case EVENT_MAC_CELL_STOP:
112 /* Process MAC cell stop request */
113 unpackMacCellStop(MacProcCellStop, pst, mBuf);
116 case EVENT_MAC_DL_CCCH_IND:
118 /* Process DL CCCH Ind */
119 unpackMacDlCcchInd(MacProcDlCcchInd, pst, mBuf);
122 case EVENT_MAC_UE_CREATE_REQ:
124 /* Process Ue Create Request */
125 unpackMacUeCreateReq(MacProcUeCreateReq, pst, mBuf);
128 case EVENT_MAC_UE_RECONFIG_REQ:
130 /* Process Ue Reconfig Request */
131 unpackMacUeReconfigReq(MacProcUeReconfigReq, pst, mBuf);
134 case EVENT_MAC_UE_DELETE_REQ:
136 /* Process UE Delete Request */
137 unpackMacUeDeleteReq(MacProcUeDeleteReq, pst, mBuf);
140 case EVENT_MAC_CELL_DELETE_REQ:
142 /* Process Cell Delete Request */
143 unpackMacCellDeleteReq(MacProcCellDeleteReq, pst, mBuf);
146 case EVENT_MAC_SLICE_CFG_REQ:
148 /* Process Slice Configuration Request */
149 unpackMacSliceCfgReq(MacProcSliceCfgReq, pst, mBuf);
152 case EVENT_MAC_SLICE_RECFG_REQ:
154 /* Process Slice Reconfiguration Request */
155 unpackMacSliceRecfgReq(MacProcSliceRecfgReq, pst, mBuf);
158 case EVENT_MAC_RACH_RESOURCE_REQ:
160 /* Process Rach Resource Request */
161 unpackMacRachRsrcReq(MacProcRachRsrcReq, pst, mBuf);
164 case EVENT_MAC_RACH_RESOURCE_REL:
166 /* Process Rach Resource Release */
167 unpackMacRachRsrcRel(MacProcRachRsrcRel, pst, mBuf);
170 case EVENT_MAC_DL_PCCH_IND:
172 /* Process Pcch indication */
173 unpackMacDlPcchInd(MacProcDlPcchInd, pst, mBuf);
184 * @brief Task Activation callback function Entity RLC.
188 * Function : MacHdlRlcEvents
190 * Process Messages received from Entity RLC
192 * @param[in] Pst *pst, Post structure of the primitive.
193 * @param[in] Buffer *mBuf, Packed primitive parameters in the buffer.
194 * @param[in] Reason reason.
197 void MacHdlRlcEvents(Pst *pst, Buffer *mBuf)
202 cmUnpkRguBndReq(RgUiRguBndReq, pst, mBuf);
205 cmUnpkRguUbndReq(RgUiRguUbndReq, pst, mBuf);
207 case EVENT_DL_DATA_TO_MAC:
208 unpackRlcDlData(MacProcRlcDlData, pst, mBuf);
210 case EVENT_BO_STATUS_TO_MAC:
211 unpackRlcBoStatus(MacProcRlcBoStatus, pst, mBuf);
220 * @brief Task Activation callback function Entity Lower MAC
224 * Function : MacHdlLwrMacEvents
226 * Process Messages received from Entity Lower MAC
228 * @param[in] Pst *pst, Post structure of the primitive.
229 * @param[in] Buffer *mBuf, Packed primitive parameters in the buffer.
230 * @param[in] Reason reason.
233 void MacHdlLwrMacEvents(Pst *pst, Buffer *mBuf)
237 case EVENT_SLOT_IND_TO_MAC:
238 unpackSlotInd(fapiMacSlotInd, pst, mBuf);
240 case EVENT_STOP_IND_TO_MAC:
241 unpackStopInd(fapiMacStopInd, pst, mBuf);
243 case EVENT_RACH_IND_TO_MAC:
244 unpackRachInd(fapiMacRachInd, pst, mBuf);
246 case EVENT_CRC_IND_TO_MAC:
247 unpackCrcInd(fapiMacCrcInd, pst, mBuf);
249 case EVENT_RX_DATA_IND_TO_MAC:
250 unpackRxDataInd(fapiMacRxDataInd, pst, mBuf);
252 case EVENT_UCI_IND_TO_MAC:
253 unpackUciInd(FapiMacUciInd, pst, mBuf);
261 #ifdef CALL_FLOW_DEBUG_LOG
263 * @brief Function prints src, dest, msg infor about all the msgs that received.
267 * Function : callFlowMacActvTsk
269 * Function prints src, dest, msg infor about all the msgs that received
271 * @param[in] Pst *pst, Post structure of the primitive.
276 void callFlowMacActvTsk(Pst *pst)
279 char destTask[50]="ENTMAC";
286 strcpy(sourceTask,"ENTDUAPP");
291 strcpy(message,"EVTLRGCFGREQ");
293 case EVTMACSCHGENCFGREQ:
294 strcpy(message,"EVTMACSCHGENCFGREQ");
296 #endif /* LCRGMILRG */
297 case EVENT_MAC_CELL_CONFIG_REQ:
298 strcpy(message,"EVENT_MAC_CELL_CONFIG_REQ");
300 case EVENT_MAC_CELL_START:
301 strcpy(message,"EVENT_MAC_CELL_START");
303 case EVENT_MAC_CELL_STOP:
304 strcpy(message,"EVENT_MAC_CELL_STOP");
306 case EVENT_MAC_DL_CCCH_IND:
307 strcpy(message,"EVENT_MAC_DL_CCCH_IND");
309 case EVENT_MAC_UE_CREATE_REQ:
310 strcpy(message,"EVENT_MAC_UE_CREATE_REQ");
312 case EVENT_MAC_UE_RECONFIG_REQ:
313 strcpy(message,"EVENT_MAC_UE_RECONFIG_REQ");
315 case EVENT_MAC_UE_DELETE_REQ:
316 strcpy(message,"EVENT_MAC_UE_DELETE_REQ");
318 case EVENT_MAC_CELL_DELETE_REQ:
319 strcpy(message,"EVENT_MAC_CELL_DELETE_REQ");
321 case EVENT_MAC_SLICE_CFG_REQ:
322 strcpy(message,"EVENT_MAC_SLICE_CFG_REQ");
324 case EVENT_MAC_SLICE_RECFG_REQ:
325 strcpy(message,"EVENT_MAC_SLICE_RECFG_REQ");
328 strcpy(message,"Invalid Event");
335 strcpy(sourceTask,"ENTRLC");
340 strcpy(message,"EVTRGUBNDREQ");
343 strcpy(message,"EVTRGUUBNDREQ");
345 case EVENT_DL_DATA_TO_MAC:
346 strcpy(message,"EVENT_DL_DATA_TO_MAC");
348 case EVENT_BO_STATUS_TO_MAC:
349 strcpy(message,"EVENT_BO_STATUS_TO_MAC");
353 strcpy(message,"Invalid Event");
361 strcpy(sourceTask,"ENTLWRMAC");
364 case EVENT_SLOT_IND_TO_MAC:
365 strcpy(message,"EVENT_SLOT_IND_TO_MAC");
367 case EVENT_STOP_IND_TO_MAC:
368 strcpy(message,"EVENT_STOP_IND_TO_MAC");
370 case EVENT_RACH_IND_TO_MAC:
371 strcpy(message,"EVENT_RACH_IND_TO_MAC");
373 case EVENT_CRC_IND_TO_MAC:
374 strcpy(message,"EVENT_CRC_IND_TO_MAC");
376 case EVENT_RX_DATA_IND_TO_MAC:
377 strcpy(message,"EVENT_RX_DATA_IND_TO_MAC");
379 case EVENT_UCI_IND_TO_MAC:
380 strcpy(message,"EVENT_UCI_IND_TO_MAC");
383 strcpy(message,"Invalid Event");
391 if(pst->srcInst == 1)
393 strcpy(sourceTask,"ENTSCH");
396 case EVENT_SLICE_CFG_RSP_TO_MAC:
398 strcpy(message,"EVENT_SLICE_CFG_RSP_TO_MAC");
401 case EVENT_SLICE_RECFG_RSP_TO_MAC:
403 strcpy(message,"EVENT_SLICE_RECFG_RSP_TO_MAC");
406 case EVENT_SCH_CELL_CFG_CFM:
408 strcpy(message,"EVENT_SCH_CELL_CFG_CFM");
411 case EVENT_UE_CONFIG_RSP_TO_MAC:
413 strcpy(message,"EVENT_UE_CONFIG_RSP_TO_MAC");
416 case EVENT_UE_RECONFIG_RSP_TO_MAC:
418 strcpy(message,"EVENT_UE_RECONFIG_RSP_TO_MAC");
421 case EVENT_DL_SCH_INFO:
423 strcpy(message,"EVENT_DL_SCH_INFO");
426 case EVENT_UL_SCH_INFO:
428 strcpy(message,"EVENT_UL_SCH_INFO");
431 case EVENT_RACH_RESOURCE_RESPONSE_TO_MAC:
433 strcpy(message,"EVENT_RACH_RESOURCE_RESPONSE_TO_MAC");
436 case EVENT_DL_PAGING_ALLOC:
438 strcpy(message,"EVENT_DL_PAGING_ALLOC");
441 case EVENT_UE_DELETE_RSP_TO_MAC:
443 strcpy(message,"EVENT_UE_DELETE_RSP_TO_MAC");
446 case EVENT_CELL_DELETE_RSP_TO_MAC:
448 strcpy(message,"EVENT_CELL_DELETE_RSP_TO_MAC");
451 case EVENT_DL_REL_HQ_PROC:
453 strcpy(message,"EVENT_DL_REL_HQ_PROC");
457 strcpy(message,"Invalid Event");
465 strcpy(sourceTask,"Invalid Source Entity Id");
469 DU_LOG("\nCall Flow: %s -> %s : %s\n", sourceTask, destTask, message);
475 * @brief Task Activation callback function.
479 * Function : macActvTsk
481 * Primitives invoked by MAC's users/providers through
482 * a loosely coupled interface arrive here by means of
483 * SSI's message handling. This API is registered with
484 * SSI during the Task Registration of MAC.
486 * @param[in] Pst *pst, Post structure of the primitive.
487 * @param[in] Buffer *mBuf, Packed primitive parameters in the buffer.
488 * @param[in] Reason reason.
492 uint8_t macActvTsk(Pst *pst, Buffer *mBuf)
495 #ifdef CALL_FLOW_DEBUG_LOG
496 callFlowMacActvTsk(pst);
502 MacHdlDuappEvents(pst, mBuf);
505 MacHdlRlcEvents(pst, mBuf);
508 MacHdlLwrMacEvents(pst, mBuf);
516 }/* end of MacActvTsk */
519 * @brief Callback function for events from entity SCH
523 * Function :MacMessageRouter
525 * Process Messages received from Entity SCH
527 * @param[in] Pst *pst, Post structure of the primitive.
528 * @param[in] Buffer *mBuf, Packed primitive parameters in the buffer.
529 * @param[in] Reason reason.
532 uint8_t MacMessageRouter(Pst *pst, void *msg)
534 #ifdef CALL_FLOW_DEBUG_LOG
535 callFlowMacActvTsk(pst);
540 case EVENT_SLICE_CFG_RSP_TO_MAC:
542 MacProcSchSliceCfgRsp(pst, (SchSliceCfgRsp *)msg);
545 case EVENT_SLICE_RECFG_RSP_TO_MAC:
547 MacProcSchSliceRecfgRsp(pst, (SchSliceRecfgRsp *)msg);
550 case EVENT_SCH_CELL_CFG_CFM:
552 MacProcSchCellCfgCfm(pst, (SchCellCfgCfm *)msg);
555 case EVENT_UE_CONFIG_RSP_TO_MAC:
557 MacProcSchUeCfgRsp(pst, (SchUeCfgRsp *)msg);
560 case EVENT_UE_RECONFIG_RSP_TO_MAC:
562 MacProcSchUeRecfgRsp(pst, (SchUeRecfgRsp *)msg);
565 case EVENT_DL_SCH_INFO:
567 MacProcDlAlloc(pst, (DlSchedInfo *)msg);
570 case EVENT_UL_SCH_INFO:
572 MacProcUlSchInfo(pst, (UlSchedInfo *)msg);
575 case EVENT_RACH_RESOURCE_RESPONSE_TO_MAC:
577 MacProcSchRachRsrcRsp(pst, (SchRachRsrcRsp *)msg);
580 case EVENT_DL_PAGING_ALLOC:
582 MacProcDlPageAlloc(pst, (DlPageAlloc *)msg);
585 case EVENT_UE_DELETE_RSP_TO_MAC:
587 MacProcSchUeDeleteRsp(pst, (SchUeDeleteRsp *)msg);
590 case EVENT_CELL_DELETE_RSP_TO_MAC:
592 MacProcSchCellDeleteRsp(pst, (SchCellDeleteRsp *)msg);
595 case EVENT_DL_REL_HQ_PROC:
597 MacSchReleaseDlHarqProc(pst, (SchRlsHqInfo *)msg);
609 /**********************************************************************
612 **********************************************************************/