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);
176 case EVENT_MAC_DL_BROADCAST_REQ:
178 /* Process Dl Broadcast Request */
179 unpackMacDlBroadcastReq(MacProcDlBroadcastReq, pst, mBuf);
183 case EVENT_MAC_UE_RESET_REQ:
185 /* Process UE Reset Request */
186 unpackMacUeResetReq(MacProcUeResetReq, pst, mBuf);
190 case EVENT_MAC_STATISTICS_REQ:
192 /* Process Statistics Request */
193 unpackMacStatsReq(MacProcStatsReq, pst, mBuf);
203 * @brief Task Activation callback function Entity RLC.
207 * Function : MacHdlRlcEvents
209 * Process Messages received from Entity RLC
211 * @param[in] Pst *pst, Post structure of the primitive.
212 * @param[in] Buffer *mBuf, Packed primitive parameters in the buffer.
213 * @param[in] Reason reason.
216 void MacHdlRlcEvents(Pst *pst, Buffer *mBuf)
221 cmUnpkRguBndReq(RgUiRguBndReq, pst, mBuf);
224 cmUnpkRguUbndReq(RgUiRguUbndReq, pst, mBuf);
226 case EVENT_DL_DATA_TO_MAC:
227 unpackRlcDlData(MacProcRlcDlData, pst, mBuf);
229 case EVENT_BO_STATUS_TO_MAC:
230 unpackRlcBoStatus(MacProcRlcBoStatus, pst, mBuf);
239 * @brief Task Activation callback function Entity Lower MAC
243 * Function : MacHdlLwrMacEvents
245 * Process Messages received from Entity Lower MAC
247 * @param[in] Pst *pst, Post structure of the primitive.
248 * @param[in] Buffer *mBuf, Packed primitive parameters in the buffer.
249 * @param[in] Reason reason.
252 void MacHdlLwrMacEvents(Pst *pst, Buffer *mBuf)
256 case EVENT_SLOT_IND_TO_MAC:
257 unpackSlotInd(fapiMacSlotInd, pst, mBuf);
259 case EVENT_STOP_IND_TO_MAC:
260 unpackStopInd(fapiMacStopInd, pst, mBuf);
262 case EVENT_RACH_IND_TO_MAC:
263 unpackRachInd(fapiMacRachInd, pst, mBuf);
265 case EVENT_CRC_IND_TO_MAC:
266 unpackCrcInd(fapiMacCrcInd, pst, mBuf);
268 case EVENT_RX_DATA_IND_TO_MAC:
269 unpackRxDataInd(fapiMacRxDataInd, pst, mBuf);
271 case EVENT_UCI_IND_TO_MAC:
272 unpackUciInd(FapiMacUciInd, pst, mBuf);
280 #ifdef CALL_FLOW_DEBUG_LOG
282 * @brief Function prints src, dest, msg infor about all the msgs that received.
286 * Function : callFlowMacActvTsk
288 * Function prints src, dest, msg infor about all the msgs that received
290 * @param[in] Pst *pst, Post structure of the primitive.
295 void callFlowMacActvTsk(Pst *pst)
298 char destTask[50]="ENTMAC";
305 strcpy(sourceTask,"ENTDUAPP");
310 strcpy(message,"EVTLRGCFGREQ");
312 case EVTMACSCHGENCFGREQ:
313 strcpy(message,"EVTMACSCHGENCFGREQ");
315 #endif /* LCRGMILRG */
316 case EVENT_MAC_CELL_CONFIG_REQ:
317 strcpy(message,"EVENT_MAC_CELL_CONFIG_REQ");
319 case EVENT_MAC_CELL_START:
320 strcpy(message,"EVENT_MAC_CELL_START");
322 case EVENT_MAC_CELL_STOP:
323 strcpy(message,"EVENT_MAC_CELL_STOP");
325 case EVENT_MAC_DL_CCCH_IND:
326 strcpy(message,"EVENT_MAC_DL_CCCH_IND");
328 case EVENT_MAC_UE_CREATE_REQ:
329 strcpy(message,"EVENT_MAC_UE_CREATE_REQ");
331 case EVENT_MAC_UE_RECONFIG_REQ:
332 strcpy(message,"EVENT_MAC_UE_RECONFIG_REQ");
334 case EVENT_MAC_UE_DELETE_REQ:
335 strcpy(message,"EVENT_MAC_UE_DELETE_REQ");
337 case EVENT_MAC_CELL_DELETE_REQ:
338 strcpy(message,"EVENT_MAC_CELL_DELETE_REQ");
340 case EVENT_MAC_SLICE_CFG_REQ:
341 strcpy(message,"EVENT_MAC_SLICE_CFG_REQ");
343 case EVENT_MAC_SLICE_RECFG_REQ:
344 strcpy(message,"EVENT_MAC_SLICE_RECFG_REQ");
346 case EVENT_MAC_STATISTICS_REQ:
347 strcpy(message,"EVENT_MAC_STATISTICS_REQ");
350 strcpy(message,"Invalid Event");
357 strcpy(sourceTask,"ENTRLC");
362 strcpy(message,"EVTRGUBNDREQ");
365 strcpy(message,"EVTRGUUBNDREQ");
367 case EVENT_DL_DATA_TO_MAC:
368 strcpy(message,"EVENT_DL_DATA_TO_MAC");
370 case EVENT_BO_STATUS_TO_MAC:
371 strcpy(message,"EVENT_BO_STATUS_TO_MAC");
375 strcpy(message,"Invalid Event");
383 strcpy(sourceTask,"ENTLWRMAC");
386 case EVENT_SLOT_IND_TO_MAC:
387 strcpy(message,"EVENT_SLOT_IND_TO_MAC");
389 case EVENT_STOP_IND_TO_MAC:
390 strcpy(message,"EVENT_STOP_IND_TO_MAC");
392 case EVENT_RACH_IND_TO_MAC:
393 strcpy(message,"EVENT_RACH_IND_TO_MAC");
395 case EVENT_CRC_IND_TO_MAC:
396 strcpy(message,"EVENT_CRC_IND_TO_MAC");
398 case EVENT_RX_DATA_IND_TO_MAC:
399 strcpy(message,"EVENT_RX_DATA_IND_TO_MAC");
401 case EVENT_UCI_IND_TO_MAC:
402 strcpy(message,"EVENT_UCI_IND_TO_MAC");
405 strcpy(message,"Invalid Event");
413 if(pst->srcInst == 1)
415 strcpy(sourceTask,"ENTSCH");
418 case EVENT_SLICE_CFG_RSP_TO_MAC:
420 strcpy(message,"EVENT_SLICE_CFG_RSP_TO_MAC");
423 case EVENT_SLICE_RECFG_RSP_TO_MAC:
425 strcpy(message,"EVENT_SLICE_RECFG_RSP_TO_MAC");
428 case EVENT_SCH_CELL_CFG_CFM:
430 strcpy(message,"EVENT_SCH_CELL_CFG_CFM");
433 case EVENT_UE_CONFIG_RSP_TO_MAC:
435 strcpy(message,"EVENT_UE_CONFIG_RSP_TO_MAC");
438 case EVENT_UE_RECONFIG_RSP_TO_MAC:
440 strcpy(message,"EVENT_UE_RECONFIG_RSP_TO_MAC");
443 case EVENT_DL_SCH_INFO:
445 strcpy(message,"EVENT_DL_SCH_INFO");
448 case EVENT_UL_SCH_INFO:
450 strcpy(message,"EVENT_UL_SCH_INFO");
453 case EVENT_RACH_RESOURCE_RESPONSE_TO_MAC:
455 strcpy(message,"EVENT_RACH_RESOURCE_RESPONSE_TO_MAC");
458 case EVENT_DL_PAGING_ALLOC:
460 strcpy(message,"EVENT_DL_PAGING_ALLOC");
463 case EVENT_UE_DELETE_RSP_TO_MAC:
465 strcpy(message,"EVENT_UE_DELETE_RSP_TO_MAC");
468 case EVENT_CELL_DELETE_RSP_TO_MAC:
470 strcpy(message,"EVENT_CELL_DELETE_RSP_TO_MAC");
473 case EVENT_DL_REL_HQ_PROC:
475 strcpy(message,"EVENT_DL_REL_HQ_PROC");
478 case EVENT_STATISTICS_RSP_TO_MAC:
480 strcpy(message,"EVENT_STATISTICS_RSP_TO_MAC");
483 case EVENT_STATISTICS_IND_TO_MAC:
485 strcpy(message,"EVENT_STATISTICS_IND_TO_MAC");
489 strcpy(message,"Invalid Event");
497 strcpy(sourceTask,"Invalid Source Entity Id");
501 DU_LOG("\nCall Flow: %s -> %s : %s\n", sourceTask, destTask, message);
507 * @brief Task Activation callback function.
511 * Function : macActvTsk
513 * Primitives invoked by MAC's users/providers through
514 * a loosely coupled interface arrive here by means of
515 * SSI's message handling. This API is registered with
516 * SSI during the Task Registration of MAC.
518 * @param[in] Pst *pst, Post structure of the primitive.
519 * @param[in] Buffer *mBuf, Packed primitive parameters in the buffer.
520 * @param[in] Reason reason.
524 uint8_t macActvTsk(Pst *pst, Buffer *mBuf)
527 #ifdef CALL_FLOW_DEBUG_LOG
528 callFlowMacActvTsk(pst);
534 MacHdlDuappEvents(pst, mBuf);
537 MacHdlRlcEvents(pst, mBuf);
540 MacHdlLwrMacEvents(pst, mBuf);
548 }/* end of MacActvTsk */
551 * @brief Callback function for events from entity SCH
555 * Function :MacMessageRouter
557 * Process Messages received from Entity SCH
559 * @param[in] Pst *pst, Post structure of the primitive.
560 * @param[in] Buffer *mBuf, Packed primitive parameters in the buffer.
561 * @param[in] Reason reason.
564 uint8_t MacMessageRouter(Pst *pst, void *msg)
566 #ifdef CALL_FLOW_DEBUG_LOG
567 callFlowMacActvTsk(pst);
572 case EVENT_SLICE_CFG_RSP_TO_MAC:
574 MacProcSchSliceCfgRsp(pst, (SchSliceCfgRsp *)msg);
577 case EVENT_SLICE_RECFG_RSP_TO_MAC:
579 MacProcSchSliceRecfgRsp(pst, (SchSliceRecfgRsp *)msg);
582 case EVENT_SCH_CELL_CFG_CFM:
584 MacProcSchCellCfgCfm(pst, (SchCellCfgCfm *)msg);
587 case EVENT_UE_CONFIG_RSP_TO_MAC:
589 MacProcSchUeCfgRsp(pst, (SchUeCfgRsp *)msg);
592 case EVENT_UE_RECONFIG_RSP_TO_MAC:
594 MacProcSchUeRecfgRsp(pst, (SchUeRecfgRsp *)msg);
597 case EVENT_DL_SCH_INFO:
599 MacProcDlAlloc(pst, (DlSchedInfo *)msg);
602 case EVENT_UL_SCH_INFO:
604 MacProcUlSchInfo(pst, (UlSchedInfo *)msg);
607 case EVENT_RACH_RESOURCE_RESPONSE_TO_MAC:
609 MacProcSchRachRsrcRsp(pst, (SchRachRsrcRsp *)msg);
612 case EVENT_DL_PAGING_ALLOC:
614 MacProcDlPageAlloc(pst, (DlPageAlloc *)msg);
617 case EVENT_UE_DELETE_RSP_TO_MAC:
619 MacProcSchUeDeleteRsp(pst, (SchUeDeleteRsp *)msg);
622 case EVENT_CELL_DELETE_RSP_TO_MAC:
624 MacProcSchCellDeleteRsp(pst, (SchCellDeleteRsp *)msg);
627 case EVENT_DL_REL_HQ_PROC:
629 MacSchReleaseDlHarqProc(pst, (SchRlsHqInfo *)msg);
632 case EVENT_STATISTICS_RSP_TO_MAC:
634 MacProcSchStatsRsp(pst, (SchStatsRsp *)msg);
637 case EVENT_STATISTICS_IND_TO_MAC:
639 MacProcSchStatsInd(pst, (SchStatsInd *)msg);
651 /**********************************************************************
654 **********************************************************************/