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 for Entry point fucntions for slot indications
29 **********************************************************************/
31 /** @file sch_slot_ind.c
32 @brief This module processes slot indications
34 #include "common_def.h"
40 #include "du_app_mac_inf.h"
41 #include "mac_sch_interface.h"
43 #include "sch_utils.h"
45 SchMacDlAllocFunc schMacDlAllocOpts[] =
52 extern SchCb schCb[SCH_MAX_INST];
53 extern int schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t
56 /*******************************************************************
58 * @brief Handles sending DL broadcast alloc to MAC
62 * Function : sendDlAllocToMac
65 * Sends DL Broadcast Resource Allocation to MAC from SCH
68 * @return ROK - success
71 * ****************************************************************/
72 int sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst)
76 memset(&pst, 0, sizeof(Pst));
77 SCH_FILL_RSP_PST(pst, inst);
78 pst.event = EVENT_DL_ALLOC;
80 return(*schMacDlAllocOpts[pst.selector])(&pst, dlSchedInfo);
85 /*******************************************************************
87 * @brief Handles slot indication at SCH
91 * Function : schCalcSlotValues
94 * Handles TTI indication received from PHY
97 * @return ROK - success
100 * ****************************************************************/
101 void schCalcSlotValues(SlotIndInfo slotInd, SchSlotValue *schSlotValue)
103 /****************************************************************
104 * PHY_DELTA - the physical layer delta *
105 * SCHED_DELTA - scheduler schedules one slot ahead *
106 * BO_DELTA - this delay is considered for BO response and *
107 * RLC buffer packet to received at MAC *
108 * lower-mac (FAPI filling) will be working on PHY_DELTA *
109 * brdcast scheduler will working on PHY_DELTA + SCHED_DELTA *
110 * RAR scheduler will working on PHY_DELTA + SCHED_DELTA *
111 * msg4 scheduler will working on PHY_DELTA + SCHED_DELTA *
112 * dedicated DL msg scheduler will working *
113 * on PHY_DELTA + SCHED_DELTA + BO_DELTA *
114 ****************************************************************/
116 ADD_DELTA_TO_TIME(slotInd,schSlotValue->currentTime,PHY_DELTA);
117 ADD_DELTA_TO_TIME(slotInd,schSlotValue->broadcastTime,PHY_DELTA+SCHED_DELTA);
118 ADD_DELTA_TO_TIME(slotInd,schSlotValue->rarTime,PHY_DELTA+SCHED_DELTA);
119 ADD_DELTA_TO_TIME(slotInd,schSlotValue->msg4Time,PHY_DELTA+SCHED_DELTA);
120 ADD_DELTA_TO_TIME(slotInd,schSlotValue->dlMsgTime,PHY_DELTA+SCHED_DELTA+BO_DELTA);
123 /*******************************************************************
125 * @brief Handles slot indication at SCH
129 * Function : schProcessSlotInd
132 * Handles TTI indication received from PHY
135 * @return ROK - success
138 * ****************************************************************/
139 uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
143 uint16_t slot, sfnSlot = 0;
144 DlSchedInfo dlSchedInfo;
145 memset(&dlSchedInfo,0,sizeof(DlSchedInfo));
146 DlBrdcstAlloc *dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
148 Msg4Alloc *msg4Alloc;
149 dlBrdcstAlloc->ssbTrans = NO_SSB;
150 dlBrdcstAlloc->sib1Trans = NO_SIB1;
152 SchCellCb *cell = schCb[schInst].cells[schInst];
154 schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue);
156 ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod;
157 memcpy(&cell->slotInfo, slotInd, sizeof(SlotIndInfo));
158 dlBrdcstAlloc->ssbIdxSupported = 1;
160 sfnSlot = ((dlSchedInfo.schSlotValue.broadcastTime.sfn * 10) +
161 dlSchedInfo.schSlotValue.broadcastTime.slot);
163 slot = dlSchedInfo.schSlotValue.currentTime.slot;
165 dlSchedInfo.cellId = cell->cellId;
167 /* Identify SSB ocassion*/
168 if (sfnSlot % SCH_MIB_TRANS == 0)
170 dlBrdcstAlloc->ssbTrans = SSB_TRANSMISSION;
172 else if (sfnSlot % ssb_rep == 0)
174 dlBrdcstAlloc->ssbTrans = SSB_REPEAT;
178 /* not SSB occassion */
181 /* Identify SIB1 occasions */
182 if(sfnSlot % cell->cellCfg.sib1SchCfg.sib1NewTxPeriod == 0)
184 dlBrdcstAlloc->sib1Trans = SIB1_TRANSMISSION;
186 else if (sfnSlot % cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod == 0)
188 dlBrdcstAlloc->sib1Trans = SIB1_REPITITION;
192 /* not SIB1 occassion */
195 if(dlBrdcstAlloc->ssbTrans || dlBrdcstAlloc->sib1Trans)
197 dlSchedInfo.isBroadcastPres = true;
198 slot = dlSchedInfo.schSlotValue.broadcastTime.slot;
199 ret = schBroadcastAlloc(cell,dlBrdcstAlloc,slot);
202 DU_LOG("\nschBroadcastAlloc failed");
208 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo != NULLP)
210 slot = dlSchedInfo.schSlotValue.rarTime.slot;
211 SCH_ALLOC(rarAlloc, sizeof(RarAlloc));
214 DU_LOG("\nMAC: Memory Allocation failed for RAR alloc");
218 dlSchedInfo.rarAlloc = rarAlloc;
220 /* RAR info is copied, this was earlier filled in schProcessRachInd */
221 memcpy(&rarAlloc->rarInfo,cell->schDlSlotInfo[slot]->rarInfo, sizeof(RarInfo));
223 /* pdcch and pdsch data is filled */
225 cell->schDlSlotInfo[slot]->rarInfo->raRnti,
226 cell->cellCfg.phyCellId,
227 cell->cellCfg.ssbSchCfg.ssbOffsetPointA);
229 SCH_FREE(cell->schDlSlotInfo[slot]->rarInfo,sizeof(RarAlloc));
230 cell->schDlSlotInfo[slot]->rarInfo = NULLP;
234 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info != NULLP)
236 slot = dlSchedInfo.schSlotValue.msg4Time.slot;
237 SCH_ALLOC(msg4Alloc, sizeof(Msg4Alloc));
240 DU_LOG("\nMAC: Memory Allocation failed for msg4 alloc");
244 dlSchedInfo.msg4Alloc = msg4Alloc;
246 /* Msg4 info is copied, this was earlier filled in macSchDlRlcBoInfo */
247 memcpy(&msg4Alloc->msg4Info, cell->schDlSlotInfo[slot]->msg4Info, \
250 /* pdcch and pdsch data is filled */
251 schDlRsrcAllocMsg4(msg4Alloc, cell, dlSchedInfo.schSlotValue.msg4Time.slot);
254 schAllocPucchResource(cell, msg4Alloc->msg4Info.crnti, dlSchedInfo.schSlotValue.msg4Time.slot);
256 SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info, sizeof(Msg4Info));
257 cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info = NULL;
261 /* send msg to MAC */
262 ret = sendDlAllocToMac(&dlSchedInfo, schInst);
265 DU_LOG("\nSending DL Broadcast allocation from SCH to MAC failed");
269 schUlResAlloc(cell, schInst);
271 memset(cell->schDlSlotInfo[slot], 0, sizeof(SchDlSlotInfo));
276 /**********************************************************************
278 **********************************************************************/