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"
44 #include "sch_utils.h"
49 /*******************************************************************
51 * @brief Handles sending DL broadcast alloc to MAC
55 * Function : sendDlAllocToMac
58 * Sends DL Broadcast Resource Allocation to MAC from SCH
61 * @return ROK - success
64 * ****************************************************************/
65 uint8_t sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst)
69 memset(&pst, 0, sizeof(Pst));
70 FILL_PST_SCH_TO_MAC(pst, inst);
71 pst.event = EVENT_DL_SCH_INFO;
73 return(MacMessageRouter(&pst, (void *)dlSchedInfo));
76 /*******************************************************************
82 * Function : schFillBoGrantDlSchedInfo
87 * @params[in] SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId
88 * @params[in] bool isRetx, SchDlHqProcCb **hqP
89 * @return ROK - success
92 * ****************************************************************/
93 bool schFillBoGrantDlSchedInfo(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, bool isRetx, SchDlHqProcCb **hqP)
95 uint8_t pdschNumSymbols = 0, pdschStartSymbol = 0;
97 uint16_t startPrb = 0;
99 uint32_t accumalatedSize = 0;
100 SchUeCb *ueCb = NULLP;
101 DlMsgSchInfo *dciSlotAlloc, *dlMsgAlloc;
102 SlotTimingInfo pdcchTime, pdschTime, pucchTime;
104 GET_CRNTI(crnti,ueId);
105 ueCb = &cell->ueCb[ueId-1];
109 if(schDlGetAvlHqProcess(cell, ueCb, hqP) != ROK)
115 if(findValidK0K1Value(cell, currTime, ueId, ueCb->k0K1TblPrsnt,\
116 &pdschStartSymbol, &pdschNumSymbols, &pdcchTime, &pdschTime, &pucchTime, isRetx, *hqP) != true )
118 /* If a valid combination of slots to scheduled PDCCH, PDSCH and PUCCH is
119 * not found, do not perform resource allocation. Return from here. */
123 /* allocate PDCCH and PDSCH resources for the ue */
124 if(cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] == NULL)
127 SCH_ALLOC(dciSlotAlloc, sizeof(DlMsgSchInfo));
130 DU_LOG("\nERROR --> SCH : Memory Allocation failed for ded DL msg alloc");
133 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = dciSlotAlloc;
134 memset(dciSlotAlloc, 0, sizeof(DlMsgSchInfo));
138 dciSlotAlloc = cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1];
140 /* Dl ded Msg info is copied, this was earlier filled in macSchDlRlcBoInfo */
141 fillDlMsgInfo(dciSlotAlloc, crnti, isRetx, *hqP);
142 dciSlotAlloc->transportBlock[0].ndi = isRetx;
144 accumalatedSize = cell->api->SchScheduleDlLc(pdcchTime, pdschTime, pdschNumSymbols, &startPrb, isRetx, hqP);
146 /*Below case will hit if NO LC(s) are allocated due to resource crunch*/
147 if (!accumalatedSize)
150 /*[Step6]: pdcch and pdsch data is filled */
151 if((schDlRsrcAllocDlMsg(cell, pdschTime, crnti, accumalatedSize, dciSlotAlloc, startPrb, pdschStartSymbol, pdschNumSymbols, isRetx, *hqP)) != ROK)
153 DU_LOG("\nERROR --> SCH : Scheduling of DL dedicated message failed");
155 /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
156 if(!dciSlotAlloc->dlMsgPdschCfg)
158 SCH_FREE(dciSlotAlloc, sizeof(DlMsgSchInfo));
159 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = NULL;
164 /* TODO : Update the scheduling byte report for multiple LC based on QCI
166 /* As of now, the total number of bytes scheduled for a slot is divided
167 * equally amongst all LC with pending data. This is avoid starving of any
171 accumalatedSize = accumalatedSize/dlMsgAlloc->numLc;
172 for(lcIdx = 0; lcIdx < dlMsgAlloc->numLc; lcIdx ++)
173 dlMsgAlloc->lcSchInfo[lcIdx].schBytes = accumalatedSize;
176 /* Check if both DCI and DL_MSG are sent in the same slot.
177 * If not, allocate memory for DL_MSG PDSCH slot to store PDSCH info */
179 if(pdcchTime.slot == pdschTime.slot)
181 SCH_ALLOC(dciSlotAlloc->dlMsgPdschCfg, sizeof(PdschCfg));
182 if(!dciSlotAlloc->dlMsgPdschCfg)
184 DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciSlotAlloc->dlMsgPdschCfg");
185 SCH_FREE(dciSlotAlloc->dlMsgPdcchCfg, sizeof(PdcchCfg));
186 SCH_FREE(dciSlotAlloc, sizeof(DlMsgSchInfo));
187 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
190 memcpy(dciSlotAlloc->dlMsgPdschCfg, &dciSlotAlloc->dlMsgPdcchCfg->dci.pdschCfg, sizeof(PdschCfg));
194 /* Allocate memory to schedule dlMsgAlloc to send DL_Msg, pointer will be checked at schProcessSlotInd() */
195 if(cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] == NULLP)
197 SCH_ALLOC(dlMsgAlloc, sizeof(DlMsgSchInfo));
198 if(dlMsgAlloc == NULLP)
200 DU_LOG("\nERROR --> SCH : Memory Allocation failed for dlMsgAlloc");
201 SCH_FREE(dciSlotAlloc->dlMsgPdcchCfg, sizeof(PdcchCfg));
202 if(dciSlotAlloc->dlMsgPdschCfg == NULLP)
204 SCH_FREE(dciSlotAlloc, sizeof(DlMsgSchInfo));
205 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
209 cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] = dlMsgAlloc;
210 memset(dlMsgAlloc, 0, sizeof(DlMsgSchInfo));
213 dlMsgAlloc = cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1];
215 /* Copy all DL_MSG info */
216 dlMsgAlloc->crnti =crnti;
217 dlMsgAlloc->bwp = dciSlotAlloc->bwp;
218 SCH_ALLOC(dlMsgAlloc->dlMsgPdschCfg, sizeof(PdschCfg));
219 if(dlMsgAlloc->dlMsgPdschCfg)
221 memcpy(dlMsgAlloc->dlMsgPdschCfg, &dciSlotAlloc->dlMsgPdcchCfg->dci.pdschCfg, sizeof(PdschCfg));
225 SCH_FREE(dciSlotAlloc->dlMsgPdcchCfg, sizeof(PdcchCfg));
226 if(dciSlotAlloc->dlMsgPdschCfg == NULLP)
228 SCH_FREE(dciSlotAlloc, sizeof(DlMsgSchInfo));
229 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
232 SCH_FREE(dlMsgAlloc, sizeof(DlMsgSchInfo));
233 cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
234 DU_LOG("\nERROR --> SCH : Memory Allocation failed for dlMsgAlloc->dlMsgPdschCfg");
239 schAllocPucchResource(cell, pucchTime, crnti, ueCb, isRetx, *hqP);
241 cell->schDlSlotInfo[pdschTime.slot]->pdschUe = ueId;
242 cell->schUlSlotInfo[pucchTime.slot]->pucchUe = ueId;
244 /*Re-setting the BO's of all DL LCs in this UE*/
245 for(lcIdx = 0; lcIdx < MAX_NUM_LC; lcIdx++)
247 ueCb->dlInfo.dlLcCtxt[lcIdx].bo = 0;
250 /* after allocation is done, unset the bo bit for that ue */
251 UNSET_ONE_BIT(ueId, cell->boIndBitMap);
255 /*******************************************************************
257 * @brief Handles sending DL Page alloc to MAC
261 * Function : sendDlPAgeAllocToMac
264 * Sends DL Page Resource Allocation to MAC from SCH
267 * @return ROK - success
270 * ****************************************************************/
271 uint8_t sendDlPageAllocToMac(DlPageAlloc *dlPageAlloc, Inst inst)
275 memset(&pst, 0, sizeof(Pst));
276 FILL_PST_SCH_TO_MAC(pst, inst);
277 pst.event = EVENT_DL_PAGING_ALLOC;
279 return(MacMessageRouter(&pst, (void *)dlPageAlloc));
282 /*******************************************************************
284 * @brief Handles slot indication at SCH
288 * Function : schCalcSlotValues
291 * Handles TTI indication received from PHY
294 * @return ROK - success
297 * ****************************************************************/
298 void schCalcSlotValues(SlotTimingInfo slotInd, SchSlotValue *schSlotValue, uint16_t numOfSlots)
300 /****************************************************************
301 * PHY_DELTA - the physical layer delta *
302 * SCHED_DELTA - scheduler schedules one slot ahead *
303 * BO_DELTA - this delay is considered for BO response and *
304 * RLC buffer packet to received at MAC *
305 * lower-mac (FAPI filling) will be working on PHY_DELTA *
306 * brdcast scheduler will working on PHY_DELTA + SCHED_DELTA *
307 * RAR scheduler will working on PHY_DELTA + SCHED_DELTA *
308 * msg4 scheduler will working on PHY_DELTA + SCHED_DELTA *
309 * dedicated DL msg scheduler will working *
310 * on PHY_DELTA + SCHED_DELTA + BO_DELTA *
311 ****************************************************************/
313 ADD_DELTA_TO_TIME(slotInd, schSlotValue->currentTime, PHY_DELTA_DL, numOfSlots);
314 ADD_DELTA_TO_TIME(slotInd, schSlotValue->broadcastTime, PHY_DELTA_DL + SCHED_DELTA, numOfSlots);
315 ADD_DELTA_TO_TIME(slotInd, schSlotValue->rarTime, PHY_DELTA_DL + SCHED_DELTA, numOfSlots);
316 ADD_DELTA_TO_TIME(slotInd, schSlotValue->dlMsgTime, PHY_DELTA_DL + SCHED_DELTA, numOfSlots);
317 ADD_DELTA_TO_TIME(slotInd, schSlotValue->ulDciTime, PHY_DELTA_DL + SCHED_DELTA, numOfSlots);
320 /*******************************************************************
322 * @brief Checks if a slot is to be scheduled for SSB transmission
326 * Function : schCheckSsbOcc
329 * Checks if a slot is to be scheduled for SSB transmission
331 * @params[in] SlotTimingInfo slotTime
333 * @return Pdu transmission
335 * ****************************************************************/
336 PduTxOccsaion schCheckSsbOcc(SchCellCb *cell, SlotTimingInfo slotTime)
340 ssb_rep = cell->cellCfg.ssbPeriod;
342 /* Identify SSB ocassion*/
343 if ((slotTime.sfn % SCH_MIB_TRANS == 0) && (slotTime.slot ==0))
345 return NEW_TRANSMISSION;
347 else if(cell->firstSsbTransmitted)
349 if((ssb_rep == 5) && ((slotTime.slot == 0 || slotTime.slot == 10)))
351 else if((slotTime.sfn % (ssb_rep/10) == 0) && slotTime.slot == 0)
354 /* not SSB occassion */
355 return NO_TRANSMISSION;
358 /*******************************************************************
360 * @brief Checks if a slot is to be scheduled for SIB1 transmission
364 * Function : schCheckSib1Occ
367 * Checks if a slot is to be scheduled for SIB1 transmission
369 * @params[in] SlotTimingInfo slotTime
371 * @return Pdu transmission
373 * ****************************************************************/
374 PduTxOccsaion schCheckSib1Occ(SchCellCb *cell, SlotTimingInfo slotTime)
376 /* Identify SIB1 occasions */
377 if((slotTime.sfn % SCH_SIB1_TRANS == 0) && (slotTime.slot ==0))
379 return NEW_TRANSMISSION;
381 else if(cell->firstSib1Transmitted)
383 if((slotTime.sfn % (SIB1_REPETITION_PERIOD/10) == 0) &&
384 (slotTime.slot == 0))
389 /* not SIB1 occassion */
390 return NO_TRANSMISSION;
393 /*******************************************************************
395 * @brief find correct combination of k0-k1 value
399 * Function : findValidK0K1Value
402 * find correct combination of k0-k1 value
404 * @params[in] SchCellCb *cell, SlotTimingInfo currTime
405 * @params[in] uint8_t ueId, bool dedMsg
406 * @params[in] uint8_t *pdschStartSymbol, uint8_t *pdschSymblLen
407 * @params[in] SlotTimingInfo *pdcchTime, SlotTimingInfo *pdschTime
408 * @params[in] SlotTimingInfo *pucchTime, bool isRetx, SchDlHqProcCb *hqP
409 * @return ROK - success
412 *******************************************************************/
413 bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, bool dedMsg,
414 uint8_t *pdschStartSymbol, uint8_t *pdschSymblLen, SlotTimingInfo *pdcchTime,
415 SlotTimingInfo *pdschTime, SlotTimingInfo *pucchTime, bool isRetx, SchDlHqProcCb *hqP)
417 uint8_t numK0 = 0, k0TblIdx = 0, k0Val = 0, k0Index =0 ;
418 uint8_t k1TblIdx = 0, k1Index = 0, k1Val = 0, numK1 = 0;
419 SchUeCb *ueCb = NULLP;
420 SchK0K1TimingInfoTbl *k0K1InfoTbl;
422 ADD_DELTA_TO_TIME(currTime, (*pdcchTime), PHY_DELTA_DL + SCHED_DELTA, cell->numSlots);
424 if(schGetSlotSymbFrmt(pdcchTime->slot, cell->slotFrmtBitMap) != DL_SLOT)
426 /* If it is not a DL slot, cannot schedule PDCCH. Return from here. */
433 ueCb = &cell->ueCb[ueId-1];
434 k0K1InfoTbl = &ueCb->k0K1InfoTbl;
435 if(schDlCandidateSelection(ueCb, *pdcchTime) == false)
437 DU_LOG("\nDEBUG --> SCH: DL candidate Selection failed bcz PDCCH is unavailable for this slot");
443 k0K1InfoTbl = &cell->k0K1InfoTbl;
446 numK0 = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].numK0;
447 for(k0TblIdx = 0; k0TblIdx < numK0; k0TblIdx++)
449 k0Index = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k0Index;
452 k0Val = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
453 *pdschStartSymbol = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol;
454 *pdschSymblLen = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol;
458 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].k0 != NULLP)
460 k0Val = *(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].k0);
461 *pdschStartSymbol = ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].startSymbol;
462 *pdschSymblLen = ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].symbolLength;
466 k0Val = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
467 *pdschStartSymbol = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol;
468 *pdschSymblLen = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol;
472 ADD_DELTA_TO_TIME((*pdcchTime), (*pdschTime), k0Val, cell->numSlots);
474 if(schGetSlotSymbFrmt(pdschTime->slot, cell->slotFrmtBitMap) != DL_SLOT)
479 if(cell->schDlSlotInfo[pdschTime->slot]->pdschUe != 0)
484 numK1 = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k1TimingInfo.numK1;
485 for(k1TblIdx = 0; k1TblIdx < numK1; k1TblIdx++)
487 k1Index = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k1TimingInfo.k1Indexes[k1TblIdx];
490 k1Val = defaultUlAckTbl[k1Index];
494 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfg.dlDataToUlAck)
496 k1Val = ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfg.dlDataToUlAck->dlDataToUlAckList[k1Index];
500 k1Val = defaultUlAckTbl[k1Index];
503 ADD_DELTA_TO_TIME((*pdschTime),(*pucchTime), k1Val, cell->numSlots);
505 if(schGetSlotSymbFrmt(pucchTime->slot, cell->slotFrmtBitMap) == DL_SLOT)
510 if(cell->schUlSlotInfo[pucchTime->slot]->pucchUe != 0)
516 ADD_DELTA_TO_TIME((*pucchTime), hqP->pucchTime, 0, cell->numSlots);
518 pdcchTime->cellId = cell->cellId;
519 pdschTime->cellId = cell->cellId;
525 * Number of symbols in case of retransmisson should be same as it was in
526 * original transmisson. Symbol availablity checks need to be added.
531 /*******************************************************************
533 * @brief Process DL Resource allocation for Page
537 * Function : schProcDlPageAlloc
539 * Functionality: Process DL Resource allocation for Page
541 * @params[in] SchCellCb *cell, SlotTimingInfo currTime, Inst schInst
543 * @return pointer to return Value(ROK, RFAILED)
545 * ****************************************************************/
546 uint8_t schProcDlPageAlloc(SchCellCb *cell, SlotTimingInfo currTime, Inst schInst)
548 DlPageAlloc dlPageAlloc;
549 CmLList *pageInfoNode = NULLP;
550 SchPageInfo *pageInfo = NULLP;
551 SlotTimingInfo pdschTime;
553 uint16_t startPrb = 0, maxFreePRB = 0, nPRB = 0;
554 uint8_t ret = RFAILED;
556 pageInfoNode = schPageInfoSearchFromPageList(currTime, &(cell->pageCb.pageIndInfoRecord[currTime.sfn]));
558 if(pageInfoNode == NULLP)
562 pageInfo = (SchPageInfo *)pageInfoNode->node;
566 dlPageAlloc.cellId = currTime.cellId;
568 ADD_DELTA_TO_TIME(currTime, dlPageAlloc.dlPageTime, PHY_DELTA_DL + SCHED_DELTA, cell->numSlots);
569 dlPageAlloc.shortMsgInd = FALSE;
570 pdschTime = dlPageAlloc.dlPageTime;
572 /*Calculate Best FREE BLOCK with MAX PRB count*/
573 maxFreePRB = searchLargestFreeBlock(cell, pdschTime, &startPrb, DIR_DL);
577 tbSize = calculateEstimateTBSize(pageInfo->msgLen, pageInfo->mcs, NUM_PDSCH_SYMBOL, maxFreePRB, &nPRB);
581 DU_LOG("\nERROR --> SCH: Unable to get any free block for Paging at SFN:%d, SLOT:%d",\
582 pdschTime.sfn, pdschTime.slot);
585 /*Fill PDCCH: PDCCH Cfg is same as SIB1 as Paging will be a broadcast message*/
586 memcpy(dlPageAlloc.pageDlDci.freqDomainResource, cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.freqDomainResource, 6 * sizeof(uint8_t));
587 dlPageAlloc.pageDlDci.durationSymbols = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.durationSymbols;
588 dlPageAlloc.pageDlDci.cceRegMappingType = INTERLEAVED_CCE_REG_MAPPING;
589 dlPageAlloc.pageDlDci.cceReg.interleaved.regBundleSize = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.regBundleSize;
590 dlPageAlloc.pageDlDci.cceReg.interleaved.interleaverSize = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.interleaverSize;
591 dlPageAlloc.pageDlDci.cceReg.interleaved.shiftIndex = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.shiftIndex;
592 dlPageAlloc.pageDlDci.ssStartSymbolIndex = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.startSymbolIndex;
593 dlPageAlloc.pageDlDci.cceIndex = cell->sib1SchCfg.sib1PdcchCfg.dci.cceIndex;
594 dlPageAlloc.pageDlDci.aggregLevel = cell->sib1SchCfg.sib1PdcchCfg.dci.aggregLevel;
595 dlPageAlloc.pageDlDci.precoderGranularity = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.precoderGranularity;
596 dlPageAlloc.pageDlDci.coreSetSize = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.coreSetSize;
598 memcpy(&dlPageAlloc.bwp, &cell->sib1SchCfg.bwp, sizeof(BwpCfg));
601 if(schFillPagePdschCfg(cell, &dlPageAlloc.pageDlSch, pdschTime, tbSize, pageInfo->mcs, startPrb) != ROK)
603 DU_LOG("\nERROR --> SCH: Issue in PDSCH Allocation for Paging at SFN:%d, SLOT:%d",\
604 pdschTime.sfn, pdschTime.slot);
608 /*Fill Page PDU information*/
609 dlPageAlloc.pageDlSch.dlPagePduLen = pageInfo->msgLen;
611 SCH_ALLOC(dlPageAlloc.pageDlSch.dlPagePdu, sizeof(dlPageAlloc.pageDlSch.dlPagePduLen));
613 if(dlPageAlloc.pageDlSch.dlPagePdu == NULLP)
615 DU_LOG("\nERROR --> SCH: Memory Allocation Failed during Page Resource allocation");
618 memcpy(dlPageAlloc.pageDlSch.dlPagePdu, pageInfo->pagePdu, dlPageAlloc.pageDlSch.dlPagePduLen);
620 /* Send msg to MAC */
621 if(sendDlPageAllocToMac(&dlPageAlloc, schInst) != ROK)
623 DU_LOG("\nERROR --> SCH : Sending DL Paging allocation from SCH to MAC failed");
624 SCH_FREE(dlPageAlloc.pageDlSch.dlPagePdu, sizeof(dlPageAlloc.pageDlSch.dlPagePduLen));
631 /*Remove the Page Node*/
632 SCH_FREE(pageInfo->pagePdu, pageInfo->msgLen);
633 schDeleteFromPageInfoList(&(cell->pageCb.pageIndInfoRecord[currTime.sfn]), pageInfoNode);
639 /*******************************************************************
641 * @brief Handles slot indication at SCH
645 * Function : SchProcSlotInd
648 * Handles TTI indication received from PHY
651 * @return ROK - success
654 * ****************************************************************/
655 uint8_t SchProcSlotInd(Pst *pst, SlotTimingInfo *slotInd)
657 uint8_t ueIdx, ret = ROK;
659 DlSchedInfo dlSchedInfo;
660 DlBrdcstAlloc *dlBrdcstAlloc = NULLP;
661 SchCellCb *cell = NULLP;
662 Inst schInst = pst->dstInst-SCH_INST_START;
663 CmLList *node = NULLP;
664 TotalPrbUsage *dlTotalPrbUsage = NULLP;
666 cell = schCb[schInst].cells[schInst];
669 DU_LOG("\nERROR --> SCH : Cell Does not exist");
672 memset(&dlSchedInfo, 0, sizeof(DlSchedInfo));
673 schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue, cell->numSlots);
674 dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
675 dlBrdcstAlloc->ssbTransmissionMode = NO_TRANSMISSION;
676 dlBrdcstAlloc->sib1TransmissionMode = NO_TRANSMISSION;
678 memcpy(&cell->slotInfo, slotInd, sizeof(SlotTimingInfo));
679 dlBrdcstAlloc->ssbIdxSupported = SSB_IDX_SUPPORTED;
681 dlSchedInfo.cellId = cell->cellId;
682 slot = dlSchedInfo.schSlotValue.broadcastTime.slot;
685 schHandleStartDrxTimer(cell);
688 /* Check for SSB occassion */
689 dlBrdcstAlloc->ssbTransmissionMode = schCheckSsbOcc(cell, dlSchedInfo.schSlotValue.broadcastTime);
690 if(dlBrdcstAlloc->ssbTransmissionMode)
692 if(schBroadcastSsbAlloc(cell, dlSchedInfo.schSlotValue.broadcastTime, dlBrdcstAlloc) != ROK)
694 DU_LOG("\nERROR --> SCH : schBroadcastSsbAlloc failed");
695 dlBrdcstAlloc->ssbTransmissionMode = NO_TRANSMISSION;
699 dlSchedInfo.isBroadcastPres = true;
700 if((dlBrdcstAlloc->ssbTransmissionMode == NEW_TRANSMISSION) && (!cell->firstSsbTransmitted))
701 cell->firstSsbTransmitted = true;
705 /* Check for SIB1 occassion */
706 dlBrdcstAlloc->sib1TransmissionMode = schCheckSib1Occ(cell, dlSchedInfo.schSlotValue.broadcastTime);
707 if(dlBrdcstAlloc->sib1TransmissionMode)
709 if(schBroadcastSib1Alloc(cell, dlSchedInfo.schSlotValue.broadcastTime, dlBrdcstAlloc) != ROK)
711 DU_LOG("\nERROR --> SCH : schBroadcastSib1Alloc failed");
712 dlBrdcstAlloc->sib1TransmissionMode = NO_TRANSMISSION;
716 dlSchedInfo.isBroadcastPres = true;
717 if((dlBrdcstAlloc->sib1TransmissionMode == NEW_TRANSMISSION) && (!cell->firstSib1Transmitted))
718 cell->firstSib1Transmitted = true;
722 /*Process Paging Msg*/
723 schProcDlPageAlloc(cell, *slotInd, schInst);
725 cell->api->SchScheduleSlot(cell, slotInd, schInst);
727 /* Check if any PDU is scheduled at this slot for any UE */
728 for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
730 /* If RAR PDCCH/PDSCH is scheduled for a UE at this slot, fill RAR specific interface
731 * structure to send to MAC */
732 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc[ueIdx] != NULLP)
734 slot = dlSchedInfo.schSlotValue.rarTime.slot;
735 dlSchedInfo.rarAlloc[ueIdx] = cell->schDlSlotInfo[slot]->rarAlloc[ueIdx];
736 cell->schDlSlotInfo[slot]->rarAlloc[ueIdx] = NULLP;
739 /* If DL-Msg PDCCH/PDSCH is scheduled for a UE at this slot, fill
740 * specific interface structure to send to MAC */
741 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx] != NULLP)
743 slot = dlSchedInfo.schSlotValue.dlMsgTime.slot;
744 dlSchedInfo.dlMsgAlloc[ueIdx] = cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx];
745 cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx] = NULLP;
749 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.ulDciTime.slot]->ulGrant != NULLP)
751 slot = dlSchedInfo.schSlotValue.ulDciTime.slot;
752 dlSchedInfo.ulGrant = cell->schDlSlotInfo[slot]->ulGrant;
753 cell->schDlSlotInfo[slot]->ulGrant = NULLP;
756 /* Send msg to MAC */
757 ret = sendDlAllocToMac(&dlSchedInfo, schInst);
760 DU_LOG("\nERROR --> SCH : Sending DL Broadcast allocation from SCH to MAC failed");
764 /* Update DL PRB Usage for all stats group which requested for DL Total PRB Usage */
765 node = cmLListFirst(&schCb[schInst].statistics.activeKpiList.dlTotPrbUseList);
768 dlTotalPrbUsage = (TotalPrbUsage *)node->node;
771 dlTotalPrbUsage->numPrbUsedForTx += cell->schDlSlotInfo[slot]->prbAlloc.numPrbAlloc;
772 dlTotalPrbUsage->totalPrbAvailForTx += MAX_NUM_RB;
777 /* Re-initialize DL slot */
778 schInitDlSlot(cell->schDlSlotInfo[slot]);
780 /* Send UL Resource allocation to MAC */
781 schUlResAlloc(cell, schInst);
784 schHandleExpiryDrxTimer(cell);
790 /**********************************************************************
792 **********************************************************************/