[Task-ID: ODUHIGH-550] Tag and Commit Id update in I-release documents
[o-du/l2.git] / src / 5gnrsch / sch_fcfs.c
index f8b73fa..28cc528 100644 (file)
@@ -41,6 +41,7 @@ File:     sch_fcfs.c
 #include "du_app_mac_inf.h"
 #include "mac_sch_interface.h"
 #include "sch.h"
+#include "sch_tmr.h"
 #include "sch_utils.h"
 #include "sch_fcfs.h"
 #ifdef NR_DRX 
@@ -976,12 +977,13 @@ uint8_t schFcfsScheduleUlLc(SlotTimingInfo dciTime, SlotTimingInfo puschTime, ui
  *         RFAILED
  *
  * ****************************************************************/
-uint32_t schFcfsScheduleDlLc(SlotTimingInfo pdcchTime, SlotTimingInfo pdschTime, uint8_t pdschNumSymbols, bool isRetx, SchDlHqProcCb **hqP)
+uint32_t schFcfsScheduleDlLc(SlotTimingInfo pdcchTime, SlotTimingInfo pdschTime, uint8_t pdschNumSymbols, \
+                               uint16_t *startPrb, bool isRetx, SchDlHqProcCb **hqP)
 {
    SchFcfsHqProcCb *fcfsHqProcCb;
    SchUeCb *ueCb;
    uint8_t lcIdx = 0;
-   uint16_t startPrb = 0, maxFreePRB = 0;
+   uint16_t maxFreePRB = 0;
    uint16_t mcsIdx = 0;
    uint32_t accumalatedSize = 0;
    CmLListCp *lcLL = NULLP;
@@ -1055,7 +1057,7 @@ uint32_t schFcfsScheduleDlLc(SlotTimingInfo pdcchTime, SlotTimingInfo pdschTime,
    }
 
    /*[Step3]: Calculate Best FREE BLOCK with MAX PRB count*/
-   maxFreePRB = searchLargestFreeBlock((*hqP)->hqEnt->cell, pdschTime, &startPrb, DIR_DL);
+   maxFreePRB = searchLargestFreeBlock((*hqP)->hqEnt->cell, pdschTime, startPrb, DIR_DL);
 
    /*[Step4]: Estimation of PRB and BO which can be allocated to each LC in
     * the list based on RRM policy*/
@@ -1071,7 +1073,7 @@ uint32_t schFcfsScheduleDlLc(SlotTimingInfo pdcchTime, SlotTimingInfo pdschTime,
          if((fcfsHqProcCb->lcCb.dedLcList.count == NULLP) || ((maxFreePRB < rsvdDedicatedPRB)))
          { 
             fcfsHqProcCb->lcCb.sharedNumPrb = maxFreePRB;
-            DU_LOG("\nDEBUG  --> SCH : DL Only Default Slice is scheduled, sharedPRB Count:%d",\
+            DU_LOG("\nDEBUG  -->  SCH : DL Only Default Slice is scheduled, sharedPRB Count:%d",\
                   fcfsHqProcCb->lcCb.sharedNumPrb);
 
             /*PRB Alloc for Default LCs*/
@@ -1156,12 +1158,13 @@ void schFcfsScheduleSlot(SchCellCb *cell, SlotTimingInfo *slotInd, Inst schInst)
    bool           isMsg4Pending = false, isMsg4Scheduled = false;
    bool           isDlMsgPending = false, isDlMsgScheduled = false;
    bool           isUlGrantPending = false, isUlGrantScheduled = false;
+   bool           isNodeFreed = false;
 
    fcfsCell = (SchFcfsCellCb *)cell->schSpcCell;
    
    /* Select first UE in the linked list to be scheduled next */
    pendingUeNode = fcfsCell->ueToBeScheduled.first;
-   if(pendingUeNode)
+   while(pendingUeNode)
    {
       if(pendingUeNode->node)
       {
@@ -1213,6 +1216,7 @@ void schFcfsScheduleSlot(SchCellCb *cell, SlotTimingInfo *slotInd, Inst schInst)
             if(isRarScheduled || isMsg4Scheduled)
             {
                schFcfsRemoveUeFrmScheduleLst(cell, pendingUeNode);
+               isNodeFreed = true;
             }
             /* If RAR/MSG4 is pending but couldnt be scheduled then,
              * put this UE at the end of linked list to be scheduled later */
@@ -1317,9 +1321,23 @@ void schFcfsScheduleSlot(SchCellCb *cell, SlotTimingInfo *slotInd, Inst schInst)
             else
             {
                schFcfsRemoveUeFrmScheduleLst(cell, pendingUeNode);
+               isNodeFreed = true;
             }
          }
       }
+      if(cell->schDlSlotInfo[slotInd->slot]->prbAlloc.numPrbAlloc >= MAX_NUM_RB)
+      {
+        DU_LOG("\nINFO   -->  SCH: No PRB available to proceed with next UE");
+        return;     
+      }
+      if(isNodeFreed == false)
+      {
+         pendingUeNode= pendingUeNode->next;
+      }
+      else
+      {
+        pendingUeNode = fcfsCell->ueToBeScheduled.first;
+      }
    }
 }