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 /*******************************************************************
54 * @brief Handles sending DL broadcast alloc to MAC
58 * Function : sendDlAllocToMac
61 * Sends DL Broadcast Resource Allocation to MAC from SCH
64 * @return ROK - success
67 * ****************************************************************/
68 uint8_t sendDlAllocToMac(DlSchedInfo *dlSchedInfo, Inst inst)
72 memset(&pst, 0, sizeof(Pst));
73 FILL_PST_SCH_TO_MAC(pst, inst);
74 pst.event = EVENT_DL_SCH_INFO;
76 return(*schMacDlAllocOpts[pst.selector])(&pst, dlSchedInfo);
80 /*******************************************************************
82 * @brief Handles slot indication at SCH
86 * Function : schCalcSlotValues
89 * Handles TTI indication received from PHY
92 * @return ROK - success
95 * ****************************************************************/
96 void schCalcSlotValues(SlotTimingInfo slotInd, SchSlotValue *schSlotValue)
98 /****************************************************************
99 * PHY_DELTA - the physical layer delta *
100 * SCHED_DELTA - scheduler schedules one slot ahead *
101 * BO_DELTA - this delay is considered for BO response and *
102 * RLC buffer packet to received at MAC *
103 * lower-mac (FAPI filling) will be working on PHY_DELTA *
104 * brdcast scheduler will working on PHY_DELTA + SCHED_DELTA *
105 * RAR scheduler will working on PHY_DELTA + SCHED_DELTA *
106 * msg4 scheduler will working on PHY_DELTA + SCHED_DELTA *
107 * dedicated DL msg scheduler will working *
108 * on PHY_DELTA + SCHED_DELTA + BO_DELTA *
109 ****************************************************************/
111 ADD_DELTA_TO_TIME(slotInd, schSlotValue->currentTime, PHY_DELTA_DL);
112 ADD_DELTA_TO_TIME(slotInd, schSlotValue->broadcastTime, PHY_DELTA_DL + SCHED_DELTA);
113 ADD_DELTA_TO_TIME(slotInd, schSlotValue->rarTime, PHY_DELTA_DL + SCHED_DELTA);
114 ADD_DELTA_TO_TIME(slotInd, schSlotValue->dlMsgTime, PHY_DELTA_DL + SCHED_DELTA);
115 ADD_DELTA_TO_TIME(slotInd, schSlotValue->ulDciTime, PHY_DELTA_DL + SCHED_DELTA);
118 /*******************************************************************
120 * @brief Checks if a slot is to be scheduled for SSB transmission
124 * Function : schCheckSsbOcc
127 * Checks if a slot is to be scheduled for SSB transmission
129 * @params[in] SlotTimingInfo slotTime
131 * @return Pdu transmission
133 * ****************************************************************/
134 PduTxOccsaion schCheckSsbOcc(SchCellCb *cell, SlotTimingInfo slotTime)
138 ssb_rep = cell->cellCfg.ssbSchCfg.ssbPeriod;
140 /* Identify SSB ocassion*/
141 if ((slotTime.sfn % SCH_MIB_TRANS == 0) && (slotTime.slot ==0))
143 return NEW_TRANSMISSION;
145 else if(cell->firstSsbTransmitted)
147 if((ssb_rep == 5) && ((slotTime.slot == 0 || slotTime.slot == 10)))
149 else if((slotTime.sfn % (ssb_rep/10) == 0) && slotTime.slot == 0)
152 /* not SSB occassion */
153 return NO_TRANSMISSION;
156 /*******************************************************************
158 * @brief Checks if a slot is to be scheduled for SIB1 transmission
162 * Function : schCheckSib1Occ
165 * Checks if a slot is to be scheduled for SIB1 transmission
167 * @params[in] SlotTimingInfo slotTime
169 * @return Pdu transmission
171 * ****************************************************************/
172 PduTxOccsaion schCheckSib1Occ(SchCellCb *cell, SlotTimingInfo slotTime)
174 /* Identify SIB1 occasions */
175 if((slotTime.sfn % SCH_SIB1_TRANS == 0) && (slotTime.slot ==0))
177 return NEW_TRANSMISSION;
179 else if(cell->firstSib1Transmitted)
181 if((slotTime.sfn % (cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod/10) == 0) &&
182 (slotTime.slot == 0))
187 /* not SIB1 occassion */
188 return NO_TRANSMISSION;
191 /*******************************************************************
193 * @brief find correct combination of k0-k1 value
197 * Function : findValidK0K1Value
200 * find correct combination of k0-k1 value
203 * @return ROK - success
206 *******************************************************************/
207 bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId, bool dedMsg, uint8_t *pdschStartSymbol, uint8_t *pdschSymblLen, SlotTimingInfo *pdcchTime, SlotTimingInfo *pdschTime, SlotTimingInfo *pucchTime)
209 uint8_t numK0 = 0, k0TblIdx = 0, k0Val = 0, k0Index =0 ;
210 uint8_t k1TblIdx = 0, k1Index = 0, k1Val = 0, numK1 = 0;
211 SchUeCb *ueCb = NULLP;
212 SchK0K1TimingInfoTbl *k0K1InfoTbl;
214 ADD_DELTA_TO_TIME(currTime, (*pdcchTime), PHY_DELTA_DL + SCHED_DELTA);
216 if(schGetSlotSymbFrmt(pdcchTime->slot, cell->slotFrmtBitMap) != DL_SLOT)
218 /* If it is not a DL slot, cannot schedule PDCCH. Return from here. */
223 if(cell->schDlSlotInfo[pdcchTime->slot]->pdcchUe != 0)
230 ueCb = &cell->ueCb[ueId-1];
231 k0K1InfoTbl = &ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1InfoTbl;
235 k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl;
238 numK0 = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].numK0;
239 for(k0TblIdx = 0; k0TblIdx < numK0; k0TblIdx++)
241 k0Index = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k0Index;
244 k0Val = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
245 *pdschStartSymbol = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol;
246 *pdschSymblLen = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol;
250 if(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].k0 != NULLP)
252 k0Val = *(ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].k0);
253 *pdschStartSymbol = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].startSymbol;
254 *pdschSymblLen = ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg.timeDomRsrcAllociList[k0Index].symbolLength;
258 ADD_DELTA_TO_TIME((*pdcchTime), (*pdschTime), k0Val);
260 if(schGetSlotSymbFrmt(pdschTime->slot, cell->slotFrmtBitMap) != DL_SLOT)
265 if(cell->schDlSlotInfo[pdschTime->slot]->pdschUe != 0)
270 numK1 = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k1TimingInfo.numK1;
271 for(k1TblIdx = 0; k1TblIdx < numK1; k1TblIdx++)
273 k1Index = k0K1InfoTbl->k0k1TimingInfo[pdcchTime->slot].k0Indexes[k0TblIdx].k1TimingInfo.k1Indexes[k1TblIdx];
276 k1Val = defaultUlAckTbl[k1Index];
280 if(ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck)
282 k1Val = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck->dlDataToUlAckList[k1Index];
285 ADD_DELTA_TO_TIME((*pdschTime),(*pucchTime), k1Val);
287 if(schGetSlotSymbFrmt(pucchTime->slot, cell->slotFrmtBitMap) == DL_SLOT)
292 if(cell->schUlSlotInfo[pucchTime->slot]->pucchUe != 0)
302 /*******************************************************************
308 * Function : schFillBoGrantDlSchedInfo
314 * @return ROK - success
317 * ****************************************************************/
318 bool schFillBoGrantDlSchedInfo(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId)
321 uint8_t pdschNumSymbols = 0, pdschStartSymbol = 0;
322 uint16_t startPrb = 0, maxFreePRB = 0;
323 uint16_t crnti = 0, mcsIdx = 0;
324 uint32_t accumalatedSize = 0;
325 SchUeCb *ueCb = NULLP;
326 CmLListCp *lcLL = NULLP;
327 DlMsgAlloc *dciSlotAlloc, *dlMsgAlloc;
328 SlotTimingInfo pdcchTime, pdschTime, pucchTime;
330 /* TX_PAYLOAD_HDR_LEN: Overhead which is to be Added once for any UE while estimating Accumulated TB Size
331 * Following flag added to keep the record whether TX_PAYLOAD_HDR_LEN is added to the first Node getting allocated.
332 * If both Dedicated and Default LC lists are present then First LC in Dedicated List will include this overhead
333 * else if only Default list is present then first node in this List will add this overhead len*/
334 bool isTxPayloadLenAdded = FALSE;
336 GET_CRNTI(crnti,ueId);
337 ueCb = &cell->ueCb[ueId-1];
339 if(findValidK0K1Value(cell, currTime, ueId, ueCb->ueCfg.spCellCfg.servCellCfg.initDlBwp.k0K1TblPrsnt,\
340 &pdschStartSymbol, &pdschNumSymbols, &pdcchTime, &pdschTime, &pucchTime) != true )
342 /* If a valid combination of slots to scheduled PDCCH, PDSCH and PUCCH is
343 * not found, do not perform resource allocation. Return from here. */
347 /* allocate PDCCH and PDSCH resources for the ue */
348 if(cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] == NULL)
351 SCH_ALLOC(dciSlotAlloc, sizeof(DlMsgAlloc));
354 DU_LOG("\nERROR --> SCH : Memory Allocation failed for ded DL msg alloc");
357 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = dciSlotAlloc;
358 memset(dciSlotAlloc, 0, sizeof(DlMsgAlloc));
359 dciSlotAlloc->crnti = crnti;
363 dciSlotAlloc = cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1];
365 /* Dl ded Msg info is copied, this was earlier filled in macSchDlRlcBoInfo */
366 fillDlMsgInfo(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].dlMsgInfo, dciSlotAlloc->crnti);
368 /*Re-Initalization per UE*/
369 /* scheduled LC data fill */
370 dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].numLc = 0;
371 isTxPayloadLenAdded = FALSE; /*Re-initlaize the flag for every UE*/
374 for(lcIdx = 0; lcIdx < MAX_NUM_LC; lcIdx++)
376 if(ueCb->dlInfo.dlLcCtxt[lcIdx].bo)
378 /*Check the LC is Dedicated or default and accordingly LCList will
380 if(ueCb->dlInfo.dlLcCtxt[lcIdx].isDedicated)
382 lcLL = &(ueCb->dlLcPrbEst.dedLcInfo->dedLcList);
386 lcLL = &(ueCb->dlLcPrbEst.defLcList);
389 /*[Step2]: Update the reqPRB and Payloadsize for this LC in the appropriate List*/
390 if(updateLcListReqPRB(lcLL, ueCb->dlInfo.dlLcCtxt[lcIdx].lcId,\
391 (ueCb->dlInfo.dlLcCtxt[lcIdx].bo + MAC_HDR_SIZE)) != ROK)
393 DU_LOG("\nERROR --> SCH : Updation in LC List Failed");
394 /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
395 if(dciSlotAlloc->numSchedInfo == 0)
397 SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
398 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = NULL;
401 memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
405 ueCb->dlInfo.dlLcCtxt[lcIdx].bo = 0;
409 if ((ueCb->dlLcPrbEst.defLcList.count == 0) && \
410 ((ueCb->dlLcPrbEst.dedLcInfo == NULL) || (ueCb->dlLcPrbEst.dedLcInfo->dedLcList.count == 0)))
412 DU_LOG("\nDEBUG --> SCH : No pending BO for any LC id\n");
413 UNSET_ONE_BIT(ueId, cell->boIndBitMap);
415 /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
416 if(dciSlotAlloc->numSchedInfo == 0)
418 SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
419 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = NULL;
422 memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
424 /*TRUE because this UE has nothing to be scheduled*/
428 /*[Step3]: Calculate Best FREE BLOCK with MAX PRB count*/
429 maxFreePRB = searchLargestFreeBlock(cell, pdschTime, &startPrb, DIR_DL);
431 /*[Step4]: Estimation of PRB and BO which can be allocated to each LC in
432 * the list based on RRM policy*/
434 /*Either this UE contains no reservedPRB pool fir dedicated S-NSSAI or
435 * Num of Free PRB available is not enough to reserve Dedicated PRBs*/
438 mcsIdx = ueCb->ueCfg.dlModInfo.mcsIndex;
439 if((ueCb->dlLcPrbEst.dedLcInfo == NULLP)
440 || ((maxFreePRB < ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB)))
442 ueCb->dlLcPrbEst.sharedNumPrb = maxFreePRB;
443 DU_LOG("\nDEBUG --> SCH : DL Only Default Slice is scheduled, sharedPRB Count:%d",\
444 ueCb->dlLcPrbEst.sharedNumPrb);
446 /*PRB Alloc for Default LCs*/
447 prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.defLcList), FALSE, mcsIdx, pdschNumSymbols,\
448 &(ueCb->dlLcPrbEst.sharedNumPrb), NULLP, &isTxPayloadLenAdded, NULLP);
452 ueCb->dlLcPrbEst.sharedNumPrb = maxFreePRB - ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB;
454 /*PRB Alloc for Dedicated LCs*/
455 prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.dedLcInfo->dedLcList), TRUE, mcsIdx, pdschNumSymbols,\
456 &(ueCb->dlLcPrbEst.sharedNumPrb), &(ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB), &isTxPayloadLenAdded, NULLP);
458 /*PRB Alloc for Default LCs*/
459 prbAllocUsingRRMPolicy(&(ueCb->dlLcPrbEst.defLcList), FALSE, mcsIdx, pdschNumSymbols, \
460 &(ueCb->dlLcPrbEst.sharedNumPrb), &(ueCb->dlLcPrbEst.dedLcInfo->rsvdDedicatedPRB), &isTxPayloadLenAdded, NULLP);
464 /*[Step5]:Traverse each LCID in LcList to calculate the exact Scheduled Bytes
465 * using allocated BO per LC and Update dlMsgAlloc(BO report for MAC*/
466 if(ueCb->dlLcPrbEst.dedLcInfo != NULLP)
467 updateGrantSizeForBoRpt(&(ueCb->dlLcPrbEst.dedLcInfo->dedLcList), dciSlotAlloc, NULLP, &(accumalatedSize));
469 updateGrantSizeForBoRpt(&(ueCb->dlLcPrbEst.defLcList), dciSlotAlloc, NULLP, &(accumalatedSize));
471 /*Below case will hit if NO LC(s) are allocated due to resource crunch*/
472 if (!accumalatedSize)
476 DU_LOG("\nERROR --> SCH : NO FREE PRB!!");
480 /*Schedule the LC for next slot*/
481 DU_LOG("\nDEBUG --> SCH : No LC has been scheduled");
483 /* Not Freeing dlMsgAlloc as ZERO BO REPORT to be sent to RLC so that
484 * Allocation can be done in next slot*/
488 /*[Step6]: pdcch and pdsch data is filled */
489 if((schDlRsrcAllocDlMsg(cell, pdschTime, crnti, accumalatedSize, dciSlotAlloc, startPrb, pdschStartSymbol, pdschNumSymbols)) != ROK)
491 DU_LOG("\nERROR --> SCH : Scheduling of DL dedicated message failed");
493 /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
494 if(dciSlotAlloc->numSchedInfo == 0)
496 SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
497 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId -1] = NULL;
500 memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
504 /* TODO : Update the scheduling byte report for multiple LC based on QCI
506 /* As of now, the total number of bytes scheduled for a slot is divided
507 * equally amongst all LC with pending data. This is avoid starving of any
511 accumalatedSize = accumalatedSize/dlMsgAlloc->numLc;
512 for(lcIdx = 0; lcIdx < dlMsgAlloc->numLc; lcIdx ++)
513 dlMsgAlloc->lcSchInfo[lcIdx].schBytes = accumalatedSize;
516 /* Check if both DCI and DL_MSG are sent in the same slot.
517 * If not, allocate memory for DL_MSG PDSCH slot to store PDSCH info */
519 if(pdcchTime.slot == pdschTime.slot)
521 dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].pduPres = BOTH;
522 dciSlotAlloc->numSchedInfo++;
526 /* Allocate memory to schedule dlMsgAlloc to send DL_Msg, pointer will be checked at schProcessSlotInd() */
527 if(cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] == NULLP)
529 SCH_ALLOC(dlMsgAlloc, sizeof(DlMsgAlloc));
530 if(dlMsgAlloc == NULLP)
532 DU_LOG("\nERROR --> SCH : Memory Allocation failed for dlMsgAlloc");
533 if(dciSlotAlloc->numSchedInfo == 0)
535 SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
536 cell->schDlSlotInfo[pdcchTime.slot]->dlMsgAlloc[ueId-1] = NULLP;
539 memset(&dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], 0, sizeof(DlMsgSchInfo));
542 cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1] = dlMsgAlloc;
543 memset(dlMsgAlloc, 0, sizeof(DlMsgAlloc));
544 dlMsgAlloc->crnti = dciSlotAlloc->crnti;
547 dlMsgAlloc = cell->schDlSlotInfo[pdschTime.slot]->dlMsgAlloc[ueId-1];
549 /* Copy all DL_MSG info */
550 memcpy(&dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo], \
551 &dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo], sizeof(DlMsgSchInfo));
552 dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo].dlMsgPdcchCfg.dci.pdschCfg = \
553 &dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo].dlMsgPdschCfg;
555 /* Assign correct PDU types in corresponding slots */
556 dlMsgAlloc->dlMsgSchedInfo[dlMsgAlloc->numSchedInfo].pduPres = PDSCH_PDU;
557 dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].pduPres = PDCCH_PDU;
558 dciSlotAlloc->dlMsgSchedInfo[dciSlotAlloc->numSchedInfo].pdschSlot = pdschTime.slot;
560 dciSlotAlloc->numSchedInfo++;
561 dlMsgAlloc->numSchedInfo++;
564 schAllocPucchResource(cell, pucchTime, crnti);
565 cell->schDlSlotInfo[pdcchTime.slot]->pdcchUe = ueId;
566 cell->schDlSlotInfo[pdschTime.slot]->pdschUe = ueId;
567 cell->schUlSlotInfo[pucchTime.slot]->pucchUe = ueId;
569 /* after allocation is done, unset the bo bit for that ue */
570 UNSET_ONE_BIT(ueId, cell->boIndBitMap);
575 /*******************************************************************
577 * @brief Handles slot indication at SCH
581 * Function : schProcessSlotInd
584 * Handles TTI indication received from PHY
587 * @return ROK - success
590 * ****************************************************************/
591 uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
593 uint8_t ueId, ueIdx, ret = ROK;
595 bool isRarPending = false, isRarScheduled = false;
596 bool isMsg4Pending = false, isMsg4Scheduled = false;
597 bool isUlGrantPending = false, isUlGrantScheduled = false;
598 bool isDlMsgPending = false, isDlMsgScheduled = false;
599 CmLList *pendingUeNode;
600 DlSchedInfo dlSchedInfo;
601 DlBrdcstAlloc *dlBrdcstAlloc = NULLP;
602 SchCellCb *cell = NULLP;
604 memset(&dlSchedInfo, 0, sizeof(DlSchedInfo));
605 schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue);
606 dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
607 dlBrdcstAlloc->ssbTrans = NO_TRANSMISSION;
608 dlBrdcstAlloc->sib1Trans = NO_TRANSMISSION;
610 cell = schCb[schInst].cells[schInst];
613 DU_LOG("\nERROR --> SCH : Cell Does not exist");
616 memcpy(&cell->slotInfo, slotInd, sizeof(SlotTimingInfo));
617 dlBrdcstAlloc->ssbIdxSupported = SSB_IDX_SUPPORTED;
619 dlSchedInfo.cellId = cell->cellId;
620 slot = dlSchedInfo.schSlotValue.broadcastTime.slot;
622 /* Check for SSB occassion */
623 dlBrdcstAlloc->ssbTrans = schCheckSsbOcc(cell, dlSchedInfo.schSlotValue.broadcastTime);
624 if(dlBrdcstAlloc->ssbTrans)
626 if(schBroadcastSsbAlloc(cell, dlSchedInfo.schSlotValue.broadcastTime, dlBrdcstAlloc) != ROK)
628 DU_LOG("\nERROR --> SCH : schBroadcastSsbAlloc failed");
629 dlBrdcstAlloc->ssbTrans = NO_TRANSMISSION;
633 dlSchedInfo.isBroadcastPres = true;
634 if((dlBrdcstAlloc->ssbTrans == NEW_TRANSMISSION) && (!cell->firstSsbTransmitted))
635 cell->firstSsbTransmitted = true;
639 /* Check for SIB1 occassion */
640 dlBrdcstAlloc->sib1Trans = schCheckSib1Occ(cell, dlSchedInfo.schSlotValue.broadcastTime);
641 if(dlBrdcstAlloc->sib1Trans)
643 if(schBroadcastSib1Alloc(cell, dlSchedInfo.schSlotValue.broadcastTime, dlBrdcstAlloc) != ROK)
645 DU_LOG("\nERROR --> SCH : schBroadcastSib1Alloc failed");
646 dlBrdcstAlloc->sib1Trans = NO_TRANSMISSION;
650 dlSchedInfo.isBroadcastPres = true;
651 if((dlBrdcstAlloc->sib1Trans == NEW_TRANSMISSION) && (!cell->firstSib1Transmitted))
652 cell->firstSib1Transmitted = true;
656 /* Select first UE in the linked list to be scheduled next */
657 pendingUeNode = cell->ueToBeScheduled.first;
660 if(pendingUeNode->node)
662 ueId = *(uint8_t *)(pendingUeNode->node);
664 /* If RAR is pending for this UE, schedule PDCCH,PDSCH to send RAR and
665 * PUSCH to receive MSG3 as per k0-k2 configuration*/
666 if(cell->raReq[ueId-1] != NULLP)
669 isRarScheduled = schProcessRaReq(schInst, cell, *slotInd, ueId);
672 /* If MSG4 is pending for this UE, schedule PDCCH,PDSCH to send MSG4 and
673 * PUCCH to receive UL msg as per k0-k1 configuration */
674 if(cell->raCb[ueId-1].msg4recvd)
676 isMsg4Pending = true;
677 isMsg4Scheduled = schProcessMsg4Req(cell, *slotInd, ueId);
680 if(isRarPending || isMsg4Pending)
682 /* If RAR or MSG is successfully scheduled then
683 * remove UE from linked list since no pending msgs for this UE */
684 if(isRarScheduled || isMsg4Scheduled)
686 SCH_FREE(pendingUeNode->node, sizeof(uint8_t));
687 deleteNodeFromLList(&cell->ueToBeScheduled, pendingUeNode);
689 /* If RAR/MSG4 is pending but couldnt be scheduled then,
690 * put this UE at the end of linked list to be scheduled later */
693 cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
697 if(cell->ueCb[ueId-1].srRcvd || cell->ueCb[ueId-1].bsrRcvd)
699 isUlGrantPending = true;
700 isUlGrantScheduled = schProcessSrOrBsrReq(cell, *slotInd, ueId);
703 if((cell->boIndBitMap) & (1<<ueId))
705 isDlMsgPending = true;
706 isDlMsgScheduled = schFillBoGrantDlSchedInfo(cell, *slotInd, ueId);
708 if(!isUlGrantPending && !isDlMsgPending)
710 /* No action required */
712 else if((isUlGrantPending && !isUlGrantScheduled) || (isDlMsgPending && !isDlMsgScheduled))
714 cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
718 SCH_FREE(pendingUeNode->node, sizeof(uint8_t));
719 deleteNodeFromLList(&cell->ueToBeScheduled, pendingUeNode);
724 /* Check if any PDU is scheduled at this slot for any UE */
725 for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
727 /* If RAR PDCCH/PDSCH is scheduled for a UE at this slot, fill RAR specific interface
728 * structure to send to MAC */
729 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc[ueIdx] != NULLP)
731 slot = dlSchedInfo.schSlotValue.rarTime.slot;
732 dlSchedInfo.rarAlloc[ueIdx] = cell->schDlSlotInfo[slot]->rarAlloc[ueIdx];
733 cell->schDlSlotInfo[slot]->rarAlloc[ueIdx] = NULLP;
736 /* If DL-Msg PDCCH/PDSCH is scheduled for a UE at this slot, fill
737 * specific interface structure to send to MAC */
738 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc[ueIdx] != NULLP)
740 slot = dlSchedInfo.schSlotValue.dlMsgTime.slot;
741 dlSchedInfo.dlMsgAlloc[ueIdx] = cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx];
742 cell->schDlSlotInfo[slot]->dlMsgAlloc[ueIdx] = NULLP;
747 if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.ulDciTime.slot]->ulGrant != NULLP)
749 slot = dlSchedInfo.schSlotValue.ulDciTime.slot;
750 dlSchedInfo.ulGrant = cell->schDlSlotInfo[slot]->ulGrant;
751 cell->schDlSlotInfo[slot]->ulGrant = NULLP;
754 /* Send msg to MAC */
755 ret = sendDlAllocToMac(&dlSchedInfo, schInst);
758 DU_LOG("\nERROR --> SCH : Sending DL Broadcast allocation from SCH to MAC failed");
762 schInitDlSlot(cell->schDlSlotInfo[slot]);
763 schUlResAlloc(cell, schInst);
768 /**********************************************************************
770 **********************************************************************/