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;
103 SchPdcchAllocInfo pdcchAllocInfo;
105 GET_CRNTI(crnti,ueId);
106 ueCb = &cell->ueCb[ueId-1];
110 if(schDlGetAvlHqProcess(cell, ueCb, hqP) != ROK)
116 memset(&pdcchAllocInfo,0,sizeof(SchPdcchAllocInfo));
117 if(findValidK0K1Value(cell, currTime, ueId, ueCb->k0K1TblPrsnt,\
118 &pdschStartSymbol, &pdschNumSymbols, &pdcchTime, &pdschTime, \
119 &pucchTime, isRetx, *hqP, &pdcchAllocInfo) != true )
121 /* If a valid combination of slots to scheduled PDCCH, PDSCH and PUCCH is
122 * not found, do not perform resource allocation. Return from here. */
126 /* allocate PDCCH and PDSCH resources for the ue */
127 if(cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] == NULL)
130 SCH_ALLOC(dciSlotAlloc, sizeof(DlMsgSchInfo));
133 DU_LOG("\nERROR --> SCH : Memory Allocation failed for ded DL msg alloc");
136 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = dciSlotAlloc;
137 memset(dciSlotAlloc, 0, sizeof(DlMsgSchInfo));
141 dciSlotAlloc = cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1];
143 /* Dl ded Msg info is copied, this was earlier filled in macSchDlRlcBoInfo */
144 fillDlMsgInfo(dciSlotAlloc, crnti, isRetx, *hqP);
145 dciSlotAlloc->transportBlock[0].ndi = isRetx;
147 accumalatedSize = cell->api->SchScheduleDlLc(pdcchTime, pdschTime, pdschNumSymbols, &startPrb, isRetx, hqP);
149 /*Below case will hit if NO LC(s) are allocated due to resource crunch*/
150 if (!accumalatedSize)
153 /*[Step6]: pdcch and pdsch data is filled */
154 if((schDlRsrcAllocDlMsg(cell, pdschTime, crnti, accumalatedSize, dciSlotAlloc, startPrb,\
155 pdschStartSymbol, pdschNumSymbols, isRetx, *hqP, pdcchAllocInfo)) != ROK)
157 DU_LOG("\nERROR --> SCH : Scheduling of DL dedicated message failed");
159 /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
160 if(!dciSlotAlloc->dlMsgPdschCfg)
162 SCH_FREE(dciSlotAlloc, sizeof(DlMsgSchInfo));
163 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = NULL;
168 /* TODO : Update the scheduling byte report for multiple LC based on QCI
170 /* As of now, the total number of bytes scheduled for a slot is divided
171 * equally amongst all LC with pending data. This is avoid starving of any
175 accumalatedSize = accumalatedSize/dlMsgAlloc->numLc;
176 for(lcIdx = 0; lcIdx < dlMsgAlloc->numLc; lcIdx ++)
177 dlMsgAlloc->lcSchInfo[lcIdx].schBytes = accumalatedSize;
180 /* Check if both DCI and DL_MSG are sent in the same slot.
181 * If not, allocate memory for DL_MSG PDSCH slot to store PDSCH info */
183 if(pdcchTime.slot == pdschTime.slot)
185 SCH_ALLOC(dciSlotAlloc->dlMsgPdschCfg, sizeof(PdschCfg));
186 if(!dciSlotAlloc->dlMsgPdschCfg)
188 DU_LOG("\nERROR --> SCH : Memory Allocation failed for dciSlotAlloc->dlMsgPdschCfg");
189 SCH_FREE(dciSlotAlloc->dlMsgPdcchCfg, sizeof(PdcchCfg));
190 SCH_FREE(dciSlotAlloc, sizeof(DlMsgSchInfo));
191 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
194 memcpy(dciSlotAlloc->dlMsgPdschCfg,\
195 &dciSlotAlloc->dlMsgPdcchCfg->dci[dciSlotAlloc->dlMsgPdcchCfg->numDlDci - 1].pdschCfg, sizeof(PdschCfg));
199 /* Allocate memory to schedule dlMsgAlloc to send DL_Msg, pointer will be checked at schProcessSlotInd() */
200 if(cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] == NULLP)
202 SCH_ALLOC(dlMsgAlloc, sizeof(DlMsgSchInfo));
203 if(dlMsgAlloc == NULLP)
205 DU_LOG("\nERROR --> SCH : Memory Allocation failed for dlMsgAlloc");
206 SCH_FREE(dciSlotAlloc->dlMsgPdcchCfg, sizeof(PdcchCfg));
207 if(dciSlotAlloc->dlMsgPdschCfg == NULLP)
209 SCH_FREE(dciSlotAlloc, sizeof(DlMsgSchInfo));
210 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
214 cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] = dlMsgAlloc;
215 memset(dlMsgAlloc, 0, sizeof(DlMsgSchInfo));
218 dlMsgAlloc = cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1];
220 /* Copy all DL_MSG info */
221 dlMsgAlloc->crnti =crnti;
222 dlMsgAlloc->bwp = dciSlotAlloc->bwp;
223 SCH_ALLOC(dlMsgAlloc->dlMsgPdschCfg, sizeof(PdschCfg));
224 if(dlMsgAlloc->dlMsgPdschCfg)
226 memcpy(dlMsgAlloc->dlMsgPdschCfg,\
227 &dciSlotAlloc->dlMsgPdcchCfg->dci[dciSlotAlloc->dlMsgPdcchCfg->numDlDci - 1].pdschCfg, sizeof(PdschCfg));
231 SCH_FREE(dciSlotAlloc->dlMsgPdcchCfg, sizeof(PdcchCfg));
232 if(dciSlotAlloc->dlMsgPdschCfg == NULLP)
234 SCH_FREE(dciSlotAlloc, sizeof(DlMsgSchInfo));
235 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
238 SCH_FREE(dlMsgAlloc, sizeof(DlMsgSchInfo));
239 cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
240 DU_LOG("\nERROR --> SCH : Memory Allocation failed for dlMsgAlloc->dlMsgPdschCfg");
245 /*Re-setting the BO's of all DL LCs in this UE*/
246 for(lcIdx = 0; lcIdx < MAX_NUM_LC; lcIdx++)
248 ueCb->dlInfo.dlLcCtxt[lcIdx].bo = 0;
251 /* after allocation is done, unset the bo bit for that ue */
252 UNSET_ONE_BIT(ueId, cell->boIndBitMap);
256 /*******************************************************************
258 * @brief Handles sending DL Page alloc to MAC
262 * Function : sendDlPAgeAllocToMac
265 * Sends DL Page Resource Allocation to MAC from SCH
268 * @return ROK - success
271 * ****************************************************************/
272 uint8_t sendDlPageAllocToMac(DlPageAlloc *dlPageAlloc, Inst inst)
276 memset(&pst, 0, sizeof(Pst));
277 FILL_PST_SCH_TO_MAC(pst, inst);
278 pst.event = EVENT_DL_PAGING_ALLOC;
280 return(MacMessageRouter(&pst, (void *)dlPageAlloc));
283 /*******************************************************************
285 * @brief Handles slot indication at SCH
289 * Function : schCalcSlotValues
292 * Handles TTI indication received from PHY
295 * @return ROK - success
298 * ****************************************************************/
299 void schCalcSlotValues(SlotTimingInfo slotInd, SchSlotValue *schSlotValue, uint16_t numOfSlots)
301 /****************************************************************
302 * PHY_DELTA - the physical layer delta *
303 * SCHED_DELTA - scheduler schedules one slot ahead *
304 * BO_DELTA - this delay is considered for BO response and *
305 * RLC buffer packet to received at MAC *
306 * lower-mac (FAPI filling) will be working on PHY_DELTA *
307 * brdcast scheduler will working on PHY_DELTA + SCHED_DELTA *
308 * RAR scheduler will working on PHY_DELTA + SCHED_DELTA *
309 * msg4 scheduler will working on PHY_DELTA + SCHED_DELTA *
310 * dedicated DL msg scheduler will working *
311 * on PHY_DELTA + SCHED_DELTA + BO_DELTA *
312 ****************************************************************/
314 ADD_DELTA_TO_TIME(slotInd, schSlotValue->currentTime, gConfigInfo.gPhyDeltaDl, numOfSlots);
315 ADD_DELTA_TO_TIME(slotInd, schSlotValue->broadcastTime, gConfigInfo.gPhyDeltaDl + SCHED_DELTA, numOfSlots);
316 ADD_DELTA_TO_TIME(slotInd, schSlotValue->rarTime, gConfigInfo.gPhyDeltaDl + SCHED_DELTA, numOfSlots);
317 ADD_DELTA_TO_TIME(slotInd, schSlotValue->dlMsgTime, gConfigInfo.gPhyDeltaDl + SCHED_DELTA, numOfSlots);
318 ADD_DELTA_TO_TIME(slotInd, schSlotValue->ulDciTime, gConfigInfo.gPhyDeltaDl + SCHED_DELTA, numOfSlots);
321 /*******************************************************************
323 * @brief Checks if a slot is to be scheduled for SSB transmission
327 * Function : schCheckSsbOcc
330 * Checks if a slot is to be scheduled for SSB transmission
332 * @params[in] SlotTimingInfo slotTime
334 * @return Pdu transmission
336 * ****************************************************************/
337 PduTxOccsaion schCheckSsbOcc(SchCellCb *cell, SlotTimingInfo slotTime)
341 ssb_rep = cell->cellCfg.ssbPeriod;
343 /* Identify SSB ocassion*/
344 if ((slotTime.sfn % SCH_MIB_TRANS == 0) && (slotTime.slot ==0))
346 return NEW_TRANSMISSION;
348 else if(cell->firstSsbTransmitted)
350 if((ssb_rep == 5) && ((slotTime.slot == 0 || slotTime.slot == 10)))
352 else if((slotTime.sfn % (ssb_rep/10) == 0) && slotTime.slot == 0)
355 /* not SSB occassion */
356 return NO_TRANSMISSION;
359 /*******************************************************************
361 * @brief Checks if a slot is to be scheduled for SIB1 transmission
365 * Function : schCheckSib1Occ
368 * Checks if a slot is to be scheduled for SIB1 transmission
370 * @params[in] SlotTimingInfo slotTime
372 * @return Pdu transmission
374 * ****************************************************************/
375 PduTxOccsaion schCheckSib1Occ(SchCellCb *cell, SlotTimingInfo slotTime)
377 /* Identify SIB1 occasions */
378 if((slotTime.sfn % SCH_SIB1_TRANS == 0) && (slotTime.slot ==0))
380 return NEW_TRANSMISSION;
382 else if(cell->firstSib1Transmitted)
384 if((slotTime.sfn % (SIB1_REPETITION_PERIOD/10) == 0) &&
385 (slotTime.slot == 0))
390 /* not SIB1 occassion */
391 return NO_TRANSMISSION;
394 /*******************************************************************
396 * @brief find correct combination of k0-k1 value
400 * Function : findValidK0K1Value
403 * find correct combination of k0-k1 value
405 * @params[in] SchCellCb *cell, SlotTimingInfo currTime
406 * @params[in] uint8_t ueId, bool dedMsg
407 * @params[in] uint8_t *pdschStartSymbol, uint8_t *pdschSymblLen
408 * @params[in] SlotTimingInfo *pdcchTime, SlotTimingInfo *pdschTime
409 * @params[in] SlotTimingInfo *pucchTime, bool isRetx, SchDlHqProcCb *hqP
410 * @return ROK - success
413 *******************************************************************/
414 bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, bool dedMsg,
415 uint8_t *pdschStartSymbol, uint8_t *pdschSymblLen, SlotTimingInfo *pdcchTime,
416 SlotTimingInfo *pdschTime, SlotTimingInfo *pucchTime, bool isRetx, SchDlHqProcCb *hqP,
417 SchPdcchAllocInfo *pdcchAllocInfo)
419 uint8_t numK0 = 0, k0TblIdx = 0, k0Val = 0, k0Index =0 ;
420 uint8_t k1TblIdx = 0, k1Index = 0, k1Val = 0, numK1 = 0;
421 uint8_t ret = RFAILED;
423 SchUeCb *ueCb = NULLP;
424 SchK0K1TimingInfoTbl *k0K1InfoTbl;
426 ADD_DELTA_TO_TIME(currTime, (*pdcchTime), gConfigInfo.gPhyDeltaDl + SCHED_DELTA, cell->numSlots);
428 if(schGetSlotSymbFrmt(pdcchTime->slot, cell->slotFrmtBitMap) != DL_SLOT)
430 /* If it is not a DL slot, cannot schedule PDCCH. Return from here. */
435 ueCb = &cell->ueCb[ueId-1];
436 GET_CRNTI(crnti, ueId);
439 k0K1InfoTbl = &ueCb->k0K1InfoTbl;
440 if(schDlCandidateSelection(ueCb, *pdcchTime, pdcchAllocInfo) == false)
442 DU_LOG("\nDEBUG --> SCH: DL candidate Selection failed bcz PDCCH is unavailable for this slot");
448 k0K1InfoTbl = &cell->k0K1InfoTbl;
451 numK0 = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].numK0;
452 for(k0TblIdx = 0; k0TblIdx < numK0; k0TblIdx++)
454 k0Index = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k0Index;
457 k0Val = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
458 *pdschStartSymbol = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol;
459 *pdschSymblLen = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol;
463 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].k0 != NULLP)
465 k0Val = *(ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].k0);
466 *pdschStartSymbol = ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].startSymbol;
467 *pdschSymblLen = ueCb->ueCfg.spCellCfg.servCellRecfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].symbolLength;
471 k0Val = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
472 *pdschStartSymbol = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol;
473 *pdschSymblLen = cell->cellCfg.dlCfgCommon.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol;
477 ADD_DELTA_TO_TIME((*pdcchTime), (*pdschTime), k0Val, cell->numSlots);
479 if(schGetSlotSymbFrmt(pdschTime->slot, cell->slotFrmtBitMap) != DL_SLOT)
485 numK1 = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k1TimingInfo.numK1;
486 for(k1TblIdx = 0; k1TblIdx < numK1; k1TblIdx++)
488 k1Index = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k1TimingInfo.k1Indexes[k1TblIdx];
491 k1Val = defaultUlAckTbl[k1Index];
495 if(ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfg.dlDataToUlAck)
497 k1Val = ueCb->ueCfg.spCellCfg.servCellRecfg.initUlBwp.pucchCfg.dlDataToUlAck->dlDataToUlAckList[k1Index];
501 k1Val = defaultUlAckTbl[k1Index];
504 ADD_DELTA_TO_TIME((*pdschTime),(*pucchTime), k1Val, cell->numSlots);
506 if(schGetSlotSymbFrmt(pucchTime->slot, cell->slotFrmtBitMap) == DL_SLOT)
511 if(cell->schUlSlotInfo[pucchTime->slot]->schPucchInfo[ueId - 1].crnti == crnti)
517 ADD_DELTA_TO_TIME((*pucchTime), hqP->pucchTime, 0, cell->numSlots);
519 pdcchTime->cellId = cell->cellId;
520 pdschTime->cellId = cell->cellId;
522 cell->schUlSlotInfo[pucchTime->slot]->schPucchInfo[ueId - 1].crnti = crnti;
524 /*Availability of PUCCH for HARQ resources*/
525 ret = schAllocPucchResource(cell, ueId, *pucchTime, ueCb, hqP, pdcchAllocInfo);
528 /*DL allocation can't go through as PUCCH is unavailable*/
537 * Number of symbols in case of retransmisson should be same as it was in
538 * original transmisson. Symbol availablity checks need to be added.
543 /*******************************************************************
545 * @brief Process DL Resource allocation for Page
549 * Function : schProcDlPageAlloc
551 * Functionality: Process DL Resource allocation for Page
553 * @params[in] SchCellCb *cell, SlotTimingInfo currTime, Inst schInst
555 * @return pointer to return Value(ROK, RFAILED)
557 * ****************************************************************/
558 uint8_t schProcDlPageAlloc(SchCellCb *cell, SlotTimingInfo currTime, Inst schInst)
560 DlPageAlloc dlPageAlloc;
561 CmLList *pageInfoNode = NULLP;
562 SchPageInfo *pageInfo = NULLP;
563 SlotTimingInfo pdschTime;
565 uint16_t startPrb = 0, maxFreePRB = 0, nPRB = 0;
566 uint8_t ret = RFAILED;
568 pageInfoNode = schPageInfoSearchFromPageList(currTime, &(cell->pageCb.pageIndInfoRecord[currTime.sfn]));
570 if(pageInfoNode == NULLP)
574 pageInfo = (SchPageInfo *)pageInfoNode->node;
578 dlPageAlloc.cellId = currTime.cellId;
580 ADD_DELTA_TO_TIME(currTime, dlPageAlloc.dlPageTime, gConfigInfo.gPhyDeltaDl + SCHED_DELTA, cell->numSlots);
581 dlPageAlloc.shortMsgInd = FALSE;
582 pdschTime = dlPageAlloc.dlPageTime;
584 /*Calculate Best FREE BLOCK with MAX PRB count*/
585 maxFreePRB = searchLargestFreeBlock(cell, pdschTime, &startPrb, DIR_DL);
589 tbSize = calculateEstimateTBSize(pageInfo->msgLen, pageInfo->mcs, NUM_PDSCH_SYMBOL, maxFreePRB, &nPRB);
593 DU_LOG("\nERROR --> SCH: Unable to get any free block for Paging at SFN:%d, SLOT:%d",\
594 pdschTime.sfn, pdschTime.slot);
597 /*Fill PDCCH: PDCCH Cfg is same as SIB1 as Paging will be a broadcast message*/
598 memcpy(dlPageAlloc.pageDlDci.freqDomainResource, cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.freqDomainResource, 6 * sizeof(uint8_t));
599 dlPageAlloc.pageDlDci.durationSymbols = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.durationSymbols;
600 dlPageAlloc.pageDlDci.cceRegMappingType = INTERLEAVED_CCE_REG_MAPPING;
601 dlPageAlloc.pageDlDci.cceReg.interleaved.regBundleSize = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.regBundleSize;
602 dlPageAlloc.pageDlDci.cceReg.interleaved.interleaverSize = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.interleaverSize;
603 dlPageAlloc.pageDlDci.cceReg.interleaved.shiftIndex = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.shiftIndex;
604 dlPageAlloc.pageDlDci.ssStartSymbolIndex = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.startSymbolIndex;
605 dlPageAlloc.pageDlDci.cceIndex = cell->sib1SchCfg.sib1PdcchCfg.dci[0].cceIndex;
606 dlPageAlloc.pageDlDci.aggregLevel = cell->sib1SchCfg.sib1PdcchCfg.dci[0].aggregLevel;
607 dlPageAlloc.pageDlDci.precoderGranularity = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.precoderGranularity;
608 dlPageAlloc.pageDlDci.coreSetSize = cell->sib1SchCfg.sib1PdcchCfg.coresetCfg.coreSetSize;
610 memcpy(&dlPageAlloc.bwp, &cell->sib1SchCfg.bwp, sizeof(BwpCfg));
613 if(schFillPagePdschCfg(cell, &dlPageAlloc.pageDlSch, pdschTime, tbSize, pageInfo->mcs, startPrb) != ROK)
615 DU_LOG("\nERROR --> SCH: Issue in PDSCH Allocation for Paging at SFN:%d, SLOT:%d",\
616 pdschTime.sfn, pdschTime.slot);
620 /*Fill Page PDU information*/
621 dlPageAlloc.pageDlSch.dlPagePduLen = pageInfo->msgLen;
623 SCH_ALLOC(dlPageAlloc.pageDlSch.dlPagePdu, sizeof(dlPageAlloc.pageDlSch.dlPagePduLen));
625 if(dlPageAlloc.pageDlSch.dlPagePdu == NULLP)
627 DU_LOG("\nERROR --> SCH: Memory Allocation Failed during Page Resource allocation");
630 memcpy(dlPageAlloc.pageDlSch.dlPagePdu, pageInfo->pagePdu, dlPageAlloc.pageDlSch.dlPagePduLen);
632 /* Send msg to MAC */
633 if(sendDlPageAllocToMac(&dlPageAlloc, schInst) != ROK)
635 DU_LOG("\nERROR --> SCH : Sending DL Paging allocation from SCH to MAC failed");
636 SCH_FREE(dlPageAlloc.pageDlSch.dlPagePdu, sizeof(dlPageAlloc.pageDlSch.dlPagePduLen));
643 /*Remove the Page Node*/
644 SCH_FREE(pageInfo->pagePdu, pageInfo->msgLen);
645 schDeleteFromPageInfoList(&(cell->pageCb.pageIndInfoRecord[currTime.sfn]), pageInfoNode);
651 /*******************************************************************
653 * @brief Handles slot indication at SCH
657 * Function : SchProcSlotInd
660 * Handles TTI indication received from PHY
663 * @return ROK - success
666 * ****************************************************************/
667 uint8_t SchProcSlotInd(Pst *pst, SlotTimingInfo *slotInd)
669 uint8_t ueIdx, ret = ROK;
671 DlSchedInfo dlSchedInfo;
672 DlBrdcstAlloc *dlBrdcstAlloc = NULLP;
673 SchCellCb *cell = NULLP;
674 Inst schInst = pst->dstInst-SCH_INST_START;
675 CmLList *node = NULLP;
676 TotalPrbUsage *dlTotalPrbUsage = NULLP;
678 cell = schCb[schInst].cells[schInst];
681 DU_LOG("\nERROR --> SCH : Cell Does not exist");
684 memset(&dlSchedInfo, 0, sizeof(DlSchedInfo));
685 schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue, cell->numSlots);
686 dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
687 dlBrdcstAlloc->ssbTransmissionMode = NO_TRANSMISSION;
688 dlBrdcstAlloc->sib1TransmissionMode = NO_TRANSMISSION;
690 memcpy(&cell->slotInfo, slotInd, sizeof(SlotTimingInfo));
691 dlBrdcstAlloc->ssbIdxSupported = SSB_IDX_SUPPORTED;
693 dlSchedInfo.cellId = cell->cellId;
694 slot = dlSchedInfo.schSlotValue.broadcastTime.slot;
697 schHandleStartDrxTimer(cell);
700 /* Check for SSB occassion */
701 dlBrdcstAlloc->ssbTransmissionMode = schCheckSsbOcc(cell, dlSchedInfo.schSlotValue.broadcastTime);
702 if(dlBrdcstAlloc->ssbTransmissionMode)
704 if(schBroadcastSsbAlloc(cell, dlSchedInfo.schSlotValue.broadcastTime, dlBrdcstAlloc) != ROK)
706 DU_LOG("\nERROR --> SCH : schBroadcastSsbAlloc failed");
707 dlBrdcstAlloc->ssbTransmissionMode = NO_TRANSMISSION;
711 dlSchedInfo.isBroadcastPres = true;
712 if((dlBrdcstAlloc->ssbTransmissionMode == NEW_TRANSMISSION) && (!cell->firstSsbTransmitted))
713 cell->firstSsbTransmitted = true;
717 /* Check for SIB1 occassion */
718 dlBrdcstAlloc->sib1TransmissionMode = schCheckSib1Occ(cell, dlSchedInfo.schSlotValue.broadcastTime);
719 if(dlBrdcstAlloc->sib1TransmissionMode)
721 if(schBroadcastSib1Alloc(cell, dlSchedInfo.schSlotValue.broadcastTime, dlBrdcstAlloc) != ROK)
723 DU_LOG("\nERROR --> SCH : schBroadcastSib1Alloc failed");
724 dlBrdcstAlloc->sib1TransmissionMode = NO_TRANSMISSION;
728 dlSchedInfo.isBroadcastPres = true;
729 if((dlBrdcstAlloc->sib1TransmissionMode == NEW_TRANSMISSION) && (!cell->firstSib1Transmitted))
730 cell->firstSib1Transmitted = true;
734 /*Process Paging Msg*/
735 schProcDlPageAlloc(cell, *slotInd, schInst);
737 cell->api->SchScheduleSlot(cell, slotInd, schInst);
739 /* Check if any PDU is scheduled at this slot for any UE */
740 for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
742 /* If RAR PDCCH/PDSCH is scheduled for a UE at this slot, fill RAR specific interface
743 * structure to send to MAC */
744 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc[ueIdx] != NULLP)
746 slot = dlSchedInfo.schSlotValue.rarTime.slot;
747 dlSchedInfo.rarAlloc[ueIdx] = cell->schDlSlotInfo[slot]->rarAlloc[ueIdx];
748 cell->schDlSlotInfo[slot]->rarAlloc[ueIdx] = NULLP;
751 /* If DL-Msg PDCCH/PDSCH is scheduled for a UE at this slot, fill
752 * specific interface structure to send to MAC */
753 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx] != NULLP)
755 slot = dlSchedInfo.schSlotValue.dlMsgTime.slot;
756 dlSchedInfo.dlMsgAlloc[ueIdx] = cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx];
757 cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx] = NULLP;
761 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.ulDciTime.slot]->ulGrant != NULLP)
763 slot = dlSchedInfo.schSlotValue.ulDciTime.slot;
764 dlSchedInfo.ulGrant = cell->schDlSlotInfo[slot]->ulGrant;
765 cell->schDlSlotInfo[slot]->ulGrant = NULLP;
768 /* Send msg to MAC */
769 ret = sendDlAllocToMac(&dlSchedInfo, schInst);
772 DU_LOG("\nERROR --> SCH : Sending DL Broadcast allocation from SCH to MAC failed");
776 /* Update DL PRB Usage for all stats group which requested for DL Total PRB Usage */
777 node = cmLListFirst(&schCb[schInst].statistics.activeKpiList.dlTotPrbUseList);
780 dlTotalPrbUsage = (TotalPrbUsage *)node->node;
783 dlTotalPrbUsage->numPrbUsedForTx += cell->schDlSlotInfo[slot]->prbAlloc.numPrbAlloc;
784 dlTotalPrbUsage->totalPrbAvailForTx += MAX_NUM_RB;
789 /* Re-initialize DL slot */
790 schInitDlSlot(cell->schDlSlotInfo[slot]);
792 /* Send UL Resource allocation to MAC */
793 schUlResAlloc(cell, schInst);
796 schHandleExpiryDrxTimer(cell);
802 /**********************************************************************
804 **********************************************************************/