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 /* header include files -- defines (.h) */
20 #include "envopt.h" /* environment options */
21 #include "envdep.h" /* environment dependent */
22 #include "envind.h" /* environment independent */
23 #include "gen.h" /* general layer */
24 #include "ssi.h" /* system services */
25 #include "cm5.h" /* common timers defines */
26 #include "cm_hash.h" /* common hash list defines */
27 #include "cm_llist.h" /* common linked list defines */
28 #include "cm_mblk.h" /* memory management */
29 #include "cm_tkns.h" /* common tokens */
30 #include "cm_lte.h" /* common tokens */
33 #include "rg_sch_inf.h"
41 /* header/extern include files (.x) */
42 #include "gen.x" /* general layer typedefs */
43 #include "ssi.x" /* system services typedefs */
44 #include "cm5.x" /* common timers */
45 #include "cm_hash.x" /* common hash list */
46 #include "cm_lib.x" /* common library */
47 #include "cm_llist.x" /* common linked list */
48 #include "cm_mblk.x" /* memory management */
49 #include "cm_tkns.x" /* common tokens */
50 #include "cm_lte.x" /* common tokens */
53 #include "rg_sch_inf.x"
57 #include "du_app_mac_inf.h"
59 #include "lwr_mac_fsm.h"
62 /* This file contains message handling functionality for MAC */
64 extern void sendToLowerMac(uint16_t msgType, uint32_t msgLen, void *msg);
66 /* Function pointer for sending crc ind from MAC to SCH */
67 MacSchCrcIndFunc macSchCrcIndOpts[]=
74 /*******************************************************************
76 * @brief Sends CRC Indication to SCH
80 * Function : sendCrcIndMacToSch
83 * Sends CRC Indication to SCH
86 * @return ROK - success
89 ****************************************************************/
90 int sendCrcIndMacToSch(CrcIndInfo *crcInd)
94 fillMacToSchPst(&pst);
95 pst.event = EVENT_CRC_IND_TO_SCH;
97 return(*macSchCrcIndOpts[pst.selector])(&pst, crcInd);
100 /*******************************************************************
102 * @brief Processes CRC Indication from PHY
106 * Function : fapiMacCrcInd
109 * Processes CRC Indication from PHY
111 * @params[in] Post Structure Pointer
112 * Crc Indication Pointer
113 * @return ROK - success
116 * ****************************************************************/
117 uint16_t fapiMacCrcInd(Pst *pst, CrcInd *crcInd)
119 CrcIndInfo crcIndInfo;
121 DU_LOG("\nMAC : Received CRC indication");
123 /* Considering one pdu and one preamble */
124 crcIndInfo.cellId = macCb.macCell->cellId;;
125 crcIndInfo.crnti = crcInd->crcInfo[0].rnti;
126 crcIndInfo.timingInfo.sfn = crcInd->timingInfo.sfn;
127 crcIndInfo.timingInfo.slot = crcInd->timingInfo.slot;
128 crcIndInfo.numCrcInd = crcInd->crcInfo[0].numCb;
129 crcIndInfo.crcInd[0] = crcInd->crcInfo[0].cbCrcStatus[0];
131 return(sendCrcIndMacToSch(&crcIndInfo));
134 /*******************************************************************
136 * @brief Process Rx Data Ind at MAC
140 * Function : fapiMacRxDataInd
143 * Process Rx Data Ind at MAC
145 * @params[in] Post structure
147 * @return ROK - success
150 * ****************************************************************/
151 uint16_t fapiMacRxDataInd(Pst *pst, RxDataInd *rxDataInd)
155 DU_LOG("\nMAC : Received Rx Data indication");
156 for(pduIdx = 0; pduIdx < rxDataInd->numPdus; pduIdx++)
158 unpackRxData(rxDataInd->timingInfo, &rxDataInd->pdus[pduIdx]);
163 /*******************************************************************
165 * @brief Processes DL data from RLC
169 * Function : MacRlcProcDlData
172 * Processes DL data from RLC
174 * @params[in] Post structure
176 * @return ROK - success
179 * ****************************************************************/
180 uint16_t MacRlcProcDlData(Pst* pst, SpId spId, RlcMacData *dlData)
185 /*******************************************************************
187 * @brief Processes BO status from RLC
191 * Function : MacRlcProcBOStatus
194 * Processes BO status from RLC
196 * @params[in] Post structure
198 * @return ROK - success
201 * ****************************************************************/
202 uint16_t MacRlcProcBOStatus(Pst* pst, SpId spId, RlcMacBOStatus* boStatus)
208 /*******************************************************************
210 * @brief Handles cell start reuqest from DU APP
214 * Function : MacHdlCellStartReq
217 * Handles cell start reuqest from DU APP
219 * @params[in] Post structure pointer
220 * Cell Start Request info pointer
221 * @return ROK - success
224 * ****************************************************************/
225 uint16_t MacHdlCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo)
227 DU_LOG("\nMAC : Handling cell start request");
228 sendToLowerMac(START_REQUEST, 0, cellStartInfo);
230 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStartInfo, \
231 sizeof(MacCellStartInfo));
236 /*******************************************************************
238 * @brief Handles cell stop request from DU APP
242 * Function : MacHdlCellStartReq
245 * Handles cell stop request from DU APP
247 * @params[in] Post structure pointer
248 * Mac Cell stop information
249 * @return ROK - success
252 * ****************************************************************/
253 uint16_t MacHdlCellStopReq(Pst *pst, MacCellStopInfo *cellStopInfo)
256 DU_LOG("\nMAC : Sending cell stop request to Lower Mac");
257 sendToLowerMac(FAPI_STOP_REQUEST, 0, cellStopInfo);
260 MAC_FREE_SHRABL_BUF(pst->region, pst->pool, cellStopInfo, \
261 sizeof(MacCellStopInfo));
266 /**********************************************************************
268 **********************************************************************/