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
35 #include "envopt.h" /* environment options */
36 #include "envdep.h" /* environment dependent */
37 #include "envind.h" /* environment independent */
38 #include "gen.h" /* general layer */
39 #include "ssi.h" /* system service interface */
40 #include "cm_tkns.h" /* Common Token Defines */
41 #include "cm_llist.h" /* Common Link List Defines */
42 #include "cm_hash.h" /* Common Hash List Defines */
43 #include "cm_mblk.h" /* common memory link list library */
44 #include "cm_lte.h" /* Common LTE Defines */
48 #include "gen.x" /* general layer typedefs */
49 #include "ssi.x" /* system services typedefs */
50 #include "cm5.x" /* system services */
51 #include "cm_tkns.x" /* Common Token Definitions */
52 #include "cm_llist.x" /* Common Link List Definitions */
53 #include "cm_lib.x" /* Common Library Definitions */
54 #include "cm_hash.x" /* Common Hash List Definitions */
55 #include "cm_mblk.x" /* common memory link list library */
56 #include "cm_lte.x" /* Common LTE Defines */
60 #include "du_app_mac_inf.h"
61 #include "mac_sch_interface.h"
63 #include "sch_utils.h"
64 #include "common_def.h"
66 SchMacDlAllocFunc schMacDlAllocOpts[] =
73 extern SchCb schCb[SCH_MAX_INST];
74 extern int schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t
77 /*******************************************************************
79 * @brief Handles sending DL broadcast alloc to MAC
83 * Function : sendDlAllocToMac
86 * Sends DL Broadcast Resource Allocation to MAC from SCH
89 * @return ROK - success
92 * ****************************************************************/
93 int sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst)
97 memset(&pst, 0, sizeof(Pst));
98 SCH_FILL_RSP_PST(pst, inst);
99 pst.event = EVENT_DL_ALLOC;
101 return(*schMacDlAllocOpts[pst.selector])(&pst, dlSchedInfo);
106 /*******************************************************************
108 * @brief Handles slot indication at SCH
112 * Function : schCalcSlotValues
115 * Handles TTI indication received from PHY
118 * @return ROK - success
121 * ****************************************************************/
122 void schCalcSlotValues(SlotIndInfo slotInd, SchSlotValue *schSlotValue)
124 /****************************************************************
125 * PHY_DELTA - the physical layer delta *
126 * SCHED_DELTA - scheduler schedules one slot ahead *
127 * BO_DELTA - this delay is considered for BO response and *
128 * RLC buffer packet to received at MAC *
129 * lower-mac (FAPI filling) will be working on PHY_DELTA *
130 * brdcast scheduler will working on PHY_DELTA + SCHED_DELTA *
131 * RAR scheduler will working on PHY_DELTA + SCHED_DELTA *
132 * msg4 scheduler will working on PHY_DELTA + SCHED_DELTA *
133 * dedicated DL msg scheduler will working *
134 * on PHY_DELTA + SCHED_DELTA + BO_DELTA *
135 ****************************************************************/
137 ADD_DELTA_TO_TIME(slotInd,schSlotValue->currentTime,PHY_DELTA);
138 ADD_DELTA_TO_TIME(slotInd,schSlotValue->broadcastTime,PHY_DELTA+SCHED_DELTA);
139 ADD_DELTA_TO_TIME(slotInd,schSlotValue->rarTime,PHY_DELTA+SCHED_DELTA);
140 ADD_DELTA_TO_TIME(slotInd,schSlotValue->msg4Time,PHY_DELTA+SCHED_DELTA);
141 ADD_DELTA_TO_TIME(slotInd,schSlotValue->dlMsgTime,PHY_DELTA+SCHED_DELTA+BO_DELTA);
144 /*******************************************************************
146 * @brief Handles slot indication at SCH
150 * Function : schProcessSlotInd
153 * Handles TTI indication received from PHY
156 * @return ROK - success
159 * ****************************************************************/
160 uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
164 uint16_t slot, sfnSlot = 0;
165 DlSchedInfo dlSchedInfo;
166 memset(&dlSchedInfo,0,sizeof(DlSchedInfo));
167 DlBrdcstAlloc *dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
169 Msg4Alloc *msg4Alloc;
170 dlBrdcstAlloc->ssbTrans = NO_SSB;
171 dlBrdcstAlloc->sib1Trans = NO_SIB1;
173 SchCellCb *cell = schCb[schInst].cells[schInst];
175 schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue);
177 ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod;
178 memcpy(&cell->slotInfo, slotInd, sizeof(SlotIndInfo));
179 dlBrdcstAlloc->ssbIdxSupported = 1;
181 sfnSlot = ((dlSchedInfo.schSlotValue.broadcastTime.sfn * 10) +
182 dlSchedInfo.schSlotValue.broadcastTime.slot);
184 slot = dlSchedInfo.schSlotValue.currentTime.slot;
186 dlSchedInfo.cellId = cell->cellId;
188 /* Identify SSB ocassion*/
189 if (sfnSlot % SCH_MIB_TRANS == 0)
191 dlBrdcstAlloc->ssbTrans = SSB_TRANSMISSION;
193 else if (sfnSlot % ssb_rep == 0)
195 dlBrdcstAlloc->ssbTrans = SSB_REPEAT;
199 /* not SSB occassion */
202 /* Identify SIB1 occasions */
203 if(sfnSlot % cell->cellCfg.sib1SchCfg.sib1NewTxPeriod == 0)
205 dlBrdcstAlloc->sib1Trans = SIB1_TRANSMISSION;
207 else if (sfnSlot % cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod == 0)
209 dlBrdcstAlloc->sib1Trans = SIB1_REPITITION;
213 /* not SIB1 occassion */
216 if(dlBrdcstAlloc->ssbTrans || dlBrdcstAlloc->sib1Trans)
218 dlSchedInfo.isBroadcastPres = true;
219 slot = dlSchedInfo.schSlotValue.broadcastTime.slot;
220 ret = schBroadcastAlloc(cell,dlBrdcstAlloc,slot);
223 DU_LOG("\nschBroadcastAlloc failed");
229 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarInfo != NULLP)
231 slot = dlSchedInfo.schSlotValue.rarTime.slot;
232 SCH_ALLOC(rarAlloc, sizeof(RarAlloc));
235 DU_LOG("\nMAC: Memory Allocation failed for RAR alloc");
239 dlSchedInfo.rarAlloc = rarAlloc;
241 /* RAR info is copied, this was earlier filled in schProcessRachInd */
242 memcpy(&rarAlloc->rarInfo,cell->schDlSlotInfo[slot]->rarInfo, sizeof(RarInfo));
244 /* pdcch and pdsch data is filled */
246 cell->schDlSlotInfo[slot]->rarInfo->raRnti,
247 cell->cellCfg.phyCellId,
248 cell->cellCfg.ssbSchCfg.ssbOffsetPointA);
250 SCH_FREE(cell->schDlSlotInfo[slot]->rarInfo,sizeof(RarAlloc));
251 cell->schDlSlotInfo[slot]->rarInfo = NULLP;
255 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.msg4Time.slot]->msg4Info != NULLP)
257 slot = dlSchedInfo.schSlotValue.msg4Time.slot;
258 SCH_ALLOC(msg4Alloc, sizeof(Msg4Alloc));
261 DU_LOG("\nMAC: Memory Allocation failed for msg4 alloc");
265 dlSchedInfo.msg4Alloc = msg4Alloc;
267 /* Msg4 info is copied, this was earlier filled in macSchDlRlcBoInfo */
268 memcpy(&msg4Alloc->msg4Info, cell->schDlSlotInfo[slot]->msg4Info, \
271 /* pdcch and pdsch data is filled */
272 schDlRsrcAllocMsg4(msg4Alloc, cell, slot);
273 SCH_FREE(cell->schDlSlotInfo[slot]->msg4Info, sizeof(Msg4Info));
274 cell->schDlSlotInfo[slot]->msg4Info = NULL;
278 /* send msg to MAC */
279 ret = sendDlAllocToMac(&dlSchedInfo, schInst);
282 DU_LOG("\nSending DL Broadcast allocation from SCH to MAC failed");
286 schUlResAlloc(cell, schInst);
288 memset(cell->schDlSlotInfo[slot], 0, sizeof(SchDlSlotInfo));
293 /**********************************************************************
295 **********************************************************************/