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 *******************************************************************************/
18 /* header include files (.h) */
19 #include "envopt.h" /* environment options */
20 #include "envdep.h" /* environment dependent */
21 #include "envind.h" /* environment independent */
22 #include "gen.h" /* general */
23 #include "ssi.h" /* system services */
24 #include "cm_tkns.h" /* Common Token Defines */
25 #include "cm_llist.h" /* Common Link List Defines */
26 #include "cm_hash.h" /* Common Hash List Defines */
27 #include "cm_mblk.h" /* common memory link list library */
28 #include "cm_lte.h" /* Common LTE Defines */
30 #include "tfu.h" /* RGU Interface includes */
32 #include "crg.h" /* layer management defines for LTE-MAC */
33 #include "rg_sch_inf.h" /* layer management defines for LTE-MAC */
37 #include "gen.x" /* general */
38 #include "ssi.x" /* system services */
39 #include "cm5.x" /* system services */
40 #include "cm_tkns.x" /* Common Token Definitions */
41 #include "cm_llist.x" /* Common Link List Definitions */
42 #include "cm_lib.x" /* Common Library Definitions */
43 #include "cm_hash.x" /* Common Hash List Definitions */
44 #include "cm_mblk.x" /* common memory link list library */
45 #include "cm_lte.x" /* Common LTE Defines */
47 #include "tfu.x" /* RGU Interface includes */
49 #include "crg.x" /* layer management typedefs for MAC */
50 #include "rg_sch_inf.x" /* SCH interface typedefs */
52 #include "du_app_mac_inf.h"
56 #include "mac_upr_inf_api.h"
58 /* function pointers for packing slot ind from mac to sch */
59 MacSchSlotIndFunc macSchSlotIndOpts[] =
67 * @brief process DL allocation from scheduler
71 * Function : MacProcDlAlloc
73 * This function copied dl sch info in the mac slot info
76 * @param[in] DL allocation from scheduler
81 int MacProcDlAlloc(Pst *pst, DlAlloc *dlAlloc)
85 MacDlSlot *currDlSlot =
86 &macCb.macCell->dlSlot[dlAlloc->slotIndInfo.slot % MAX_SLOT_SUPPORTED];
87 memcpy(&currDlSlot->dlInfo, dlAlloc, sizeof(DlAlloc));
89 if(currDlSlot->dlInfo.msg4Alloc)
92 * Step1 : Fetch msg4 from raCb that was filled in MacHdlDlCcchInd()
94 * Step3 : Store the pdu in raCb
102 * @brief Transmission time interval indication from PHY.
106 * Function : sendSlotIndMacToSch
108 * This API is invoked by MAC to send slot ind to scheduler.
110 * @param[in] SlotIndInfo *slotInd
115 int sendSlotIndMacToSch(SlotIndInfo *slotInd)
117 /* fill Pst structure to send to lwr_mac to MAC */
120 fillMacToSchPst(&pst);
121 pst.event = EVENT_SLOT_IND_TO_SCH;
123 return(*macSchSlotIndOpts[pst.selector])(&pst,slotInd);
126 /*******************************************************************
128 * @brief Send slot indication to DU APP
132 * Function : sendSlotIndMacToDuApp
135 * Send slot indication to DU APP
137 * @params[in] Slot indication info
138 * @return ROK - success
141 * ****************************************************************/
142 int sendSlotIndMacToDuApp(SlotIndInfo *slotInd)
148 /* Allocate sharable memory */
149 MAC_ALLOC_SHRABL_BUF(slotInfo, sizeof(SlotInfo));
152 DU_LOG("\nMAC : Slot Indication memory allocation failed");
156 slotInfo->cellId = macCb.macCell->cellId;
157 slotInfo->sfn = slotInd->sfn;
158 slotInfo->slot = slotInd->slot;
161 pst.selector = DU_MAC_LWLC;
163 pst.dstEnt = ENTDUAPP;
165 pst.srcInst = macCb.macInst;
166 pst.dstProcId = rgCb[pst.srcInst].rgInit.procId;
167 pst.srcProcId = rgCb[pst.srcInst].rgInit.procId;
168 pst.region = MAC_MEM_REGION;
170 pst.event = EVENT_MAC_SLOT_IND;
175 ret = MacDuAppSlotInd(&pst, slotInfo);
178 DU_LOG("\nMAC: Failed to send slot indication to DU APP");
179 MAC_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, slotInfo, sizeof(SlotInfo));
183 } /* sendSlotIndMacToDuApp */
187 * @brief Transmission time interval indication from PHY.
191 * Function : fapiMacSlotInd
193 * This API is invoked by PHY to indicate TTI indication to MAC for a cell.
195 * @param[in] Pst *pst
196 * @param[in] SuId suId
197 * @param[in] SlotIndInfo *slotInd
202 PUBLIC S16 fapiMacSlotInd
209 VOLATILE U32 startTime=0;
212 DU_LOG("\nMAC : Slot Indication received");
216 SStartTask(&startTime, PID_MAC_TTI_IND);
218 /* send slot indication to scheduler */
219 ret = sendSlotIndMacToSch(slotInd);
222 DU_LOG("\nMAC : Sending of slot ind msg from MAC to SCH failed");
226 ret = macProcessSlotInd(inst,*slotInd);
229 DU_LOG("\nMAC : macProcessSlotInd failed");
233 /* send slot indication to du app */
234 ret = sendSlotIndMacToDuApp(slotInd);
237 DU_LOG("\nMAC :Sending of slot ind msg from MAC to DU APP failed");
242 SStopTask(startTime, PID_MAC_TTI_IND);
245 } /* fapiMacSlotInd */
247 /**********************************************************************
249 **********************************************************************/