Round Robin Scheduling of Multi-UE [Issue-ID: ODUHIGH-387]
[o-du/l2.git] / src / 5gnrsch / sch_slot_ind.c
index 913111c..33e5f2a 100644 (file)
@@ -290,10 +290,11 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
             ((ueCb->dlLcPrbEst.dedLcInfo != NULL) && (ueCb->dlLcPrbEst.dedLcInfo->dedLcList.count == 0)))
       {
          DU_LOG("\nDEBUG  -->  SCH : No pending BO for any LC id\n");
+         UNSET_ONE_BIT(ueIdx, cell->boIndBitMap);
          /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
          SCH_FREE(dlMsgAlloc, sizeof(DlMsgAlloc));
          dlSchedInfo->dlMsgAlloc = NULLP;
-         return ROK;
+         continue;
       }
 
       /*[Step3]: Calculate Best FREE BLOCK with MAX PRB count*/
@@ -422,12 +423,14 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
  * ****************************************************************/
 uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
 {
-   uint8_t  ueIdx, lcgIdx, ret = ROK;
-   uint16_t slot;
-   DlSchedInfo dlSchedInfo;
+   uint8_t   ueId, ueIdx, lcgIdx, ret = ROK;
+   uint16_t  slot;
+   bool      isRarScheduled = false;
+   CmLList       *pendingUeNode;
+   DlSchedInfo   dlSchedInfo;
    DlBrdcstAlloc *dlBrdcstAlloc = NULLP;
-   DlMsgAlloc *dlMsgAlloc = NULLP;
-   SchCellCb  *cell = NULLP;
+   DlMsgAlloc    *dlMsgAlloc = NULLP;
+   SchCellCb     *cell = NULLP;
 
    memset(&dlSchedInfo,0,sizeof(DlSchedInfo));
    dlSchedInfo.dlMsgAlloc = NULLP;
@@ -482,15 +485,41 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
       }
    }
 
-   /* Check for Pending RA Requests */
-   schProcessRaReq(*slotInd, cell);
+   /* Select first UE in the linked list to be scheduled next */
+   pendingUeNode = cell->ueToBeScheduled.first;
+   if(pendingUeNode)
+   {
+      ueId = *(uint8_t *)(pendingUeNode->node);
+
+      /* Check for Pending RA Requests */
+      if(cell->raReq[ueId-1] != NULLP)
+      {
+         isRarScheduled = schProcessRaReq(cell, *slotInd, ueId);
+         /* If RAR scheduled for this UE, remove from linked list since no
+          * pending msgs for this UE */
+         if(isRarScheduled)
+         {
+            SCH_FREE(pendingUeNode->node, sizeof(uint8_t));
+            deleteNodeFromLList(&cell->ueToBeScheduled, pendingUeNode);
+         }
+         /* If RAR couldnt be scheduled, put this UE at the end of linked 
+          * list to be scheduled later */
+         else
+         {
+            cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
+         }
+      }
+   }
 
    /* Check for RAR */
-   if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc != NULLP)
+   for(ueIdx=0; ueIdx<MAX_NUM_UE; ueIdx++)
    {
-      slot = dlSchedInfo.schSlotValue.rarTime.slot;
-      dlSchedInfo.rarAlloc = cell->schDlSlotInfo[slot]->rarAlloc;
-      cell->schDlSlotInfo[slot]->rarAlloc = NULLP;
+      if(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.rarTime.slot]->rarAlloc[ueIdx] != NULLP)
+      {
+         slot = dlSchedInfo.schSlotValue.rarTime.slot;
+         dlSchedInfo.rarAlloc[ueIdx] = cell->schDlSlotInfo[slot]->rarAlloc[ueIdx];
+         cell->schDlSlotInfo[slot]->rarAlloc[ueIdx] = NULLP;
+      }
    }
    
    schProcessMsg4Req(cell, *slotInd);