[Epic-ID: ODUHIGH-462][Task-ID: ODUHIGH-472] Implementation of onduration timer
[o-du/l2.git] / src / 5gnrsch / sch_slot_ind.c
index 052a930..0877485 100644 (file)
@@ -131,7 +131,7 @@ uint8_t sendDlPageAllocToMac(DlPageAlloc *dlPageAlloc, Inst inst)
  *         RFAILED - failure
  *
  * ****************************************************************/
-void schCalcSlotValues(SlotTimingInfo slotInd, SchSlotValue *schSlotValue)
+void schCalcSlotValues(SlotTimingInfo slotInd, SchSlotValue *schSlotValue, uint16_t numOfSlots)
 {
    /****************************************************************
     * PHY_DELTA - the physical layer delta                         * 
@@ -146,11 +146,11 @@ void schCalcSlotValues(SlotTimingInfo slotInd, SchSlotValue *schSlotValue)
     *        on PHY_DELTA + SCHED_DELTA + BO_DELTA                 *
     ****************************************************************/
 
-   ADD_DELTA_TO_TIME(slotInd, schSlotValue->currentTime, PHY_DELTA_DL);
-   ADD_DELTA_TO_TIME(slotInd, schSlotValue->broadcastTime, PHY_DELTA_DL + SCHED_DELTA);
-   ADD_DELTA_TO_TIME(slotInd, schSlotValue->rarTime, PHY_DELTA_DL + SCHED_DELTA);
-   ADD_DELTA_TO_TIME(slotInd, schSlotValue->dlMsgTime, PHY_DELTA_DL + SCHED_DELTA);
-   ADD_DELTA_TO_TIME(slotInd, schSlotValue->ulDciTime, PHY_DELTA_DL + SCHED_DELTA);
+   ADD_DELTA_TO_TIME(slotInd, schSlotValue->currentTime, PHY_DELTA_DL, numOfSlots);
+   ADD_DELTA_TO_TIME(slotInd, schSlotValue->broadcastTime, PHY_DELTA_DL + SCHED_DELTA, numOfSlots);
+   ADD_DELTA_TO_TIME(slotInd, schSlotValue->rarTime, PHY_DELTA_DL + SCHED_DELTA, numOfSlots);
+   ADD_DELTA_TO_TIME(slotInd, schSlotValue->dlMsgTime, PHY_DELTA_DL + SCHED_DELTA, numOfSlots);
+   ADD_DELTA_TO_TIME(slotInd, schSlotValue->ulDciTime, PHY_DELTA_DL + SCHED_DELTA, numOfSlots);
 }
 
 /*******************************************************************
@@ -255,7 +255,7 @@ bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId,
    SchUeCb *ueCb = NULLP;
    SchK0K1TimingInfoTbl *k0K1InfoTbl;
 
-   ADD_DELTA_TO_TIME(currTime, (*pdcchTime), PHY_DELTA_DL + SCHED_DELTA);
+   ADD_DELTA_TO_TIME(currTime, (*pdcchTime), PHY_DELTA_DL + SCHED_DELTA, cell->numSlots);
 #ifdef NR_TDD
    if(schGetSlotSymbFrmt(pdcchTime->slot, cell->slotFrmtBitMap) != DL_SLOT)
    {
@@ -299,7 +299,7 @@ bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId,
          }
       }
 
-      ADD_DELTA_TO_TIME((*pdcchTime), (*pdschTime), k0Val);
+      ADD_DELTA_TO_TIME((*pdcchTime), (*pdschTime), k0Val, cell->numSlots);
 #ifdef NR_TDD
       if(schGetSlotSymbFrmt(pdschTime->slot, cell->slotFrmtBitMap) != DL_SLOT)
       {
@@ -326,7 +326,7 @@ bool findValidK0K1Value(SchCellCb *cell, SlotTimingInfo currTime, uint8_t ueId,
                k1Val = ueCb->ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg.dlDataToUlAck->dlDataToUlAckList[k1Index];
             }
          }
-         ADD_DELTA_TO_TIME((*pdschTime),(*pucchTime), k1Val);
+         ADD_DELTA_TO_TIME((*pdschTime),(*pucchTime), k1Val, cell->numSlots);
 #ifdef NR_TDD
          if(schGetSlotSymbFrmt(pucchTime->slot, cell->slotFrmtBitMap) == DL_SLOT)
          {
@@ -681,7 +681,7 @@ uint8_t schProcDlPageAlloc(SchCellCb *cell, SlotTimingInfo currTime, Inst schIns
    {
       dlPageAlloc.cellId = currTime.cellId;
 
-      ADD_DELTA_TO_TIME(currTime, dlPageAlloc.dlPageTime, PHY_DELTA_DL + SCHED_DELTA);
+      ADD_DELTA_TO_TIME(currTime, dlPageAlloc.dlPageTime, PHY_DELTA_DL + SCHED_DELTA, cell->numSlots);
       dlPageAlloc.shortMsgInd  = FALSE;
       pdschTime = dlPageAlloc.dlPageTime;
 
@@ -778,18 +778,18 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
    SchDlHqProcCb  *hqP = NULLP;
    SchUlHqProcCb *ulHqP = NULLP;
 
-   memset(&dlSchedInfo, 0, sizeof(DlSchedInfo));
-   schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue);
-   dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
-   dlBrdcstAlloc->ssbTrans = NO_TRANSMISSION;
-   dlBrdcstAlloc->sib1Trans = NO_TRANSMISSION;
-
    cell = schCb[schInst].cells[schInst];
    if(cell == NULLP)
    {
       DU_LOG("\nERROR  -->  SCH : Cell Does not exist");
       return RFAILED;
    }
+   memset(&dlSchedInfo, 0, sizeof(DlSchedInfo));
+   schCalcSlotValues(*slotInd, &dlSchedInfo.schSlotValue, cell->numSlots);
+   dlBrdcstAlloc = &dlSchedInfo.brdcstAlloc;
+   dlBrdcstAlloc->ssbTrans = NO_TRANSMISSION;
+   dlBrdcstAlloc->sib1Trans = NO_TRANSMISSION;
+
    memcpy(&cell->slotInfo, slotInd, sizeof(SlotTimingInfo));
    dlBrdcstAlloc->ssbIdxSupported = SSB_IDX_SUPPORTED;
 
@@ -845,7 +845,6 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
       {
          ueNode = (uint8_t *)pendingUeNode->node;
          ueId = *(uint8_t *)(pendingUeNode->node);
-         
          /* If RAR is pending for this UE, schedule PDCCH,PDSCH to send RAR and 
           * PUSCH to receive MSG3 as per k0-k2 configuration*/
          if(cell->raReq[ueId-1] != NULLP)
@@ -860,14 +859,6 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
             schMsg3RetxSchedulingForUe(&(cell->raCb[ueId-1]));
          }
 
-#ifdef NR_DRX 
-         if(!(cell->ueCb[ueId-1].ueDrxInfoPres) && !(cell->ueCb[ueId-1].drxUeCb.drxDlUeActiveStatus))//&&  !(cell->ueCb[ueId-1].drxUeCb.drxUlUeActiveStatus))
-         {
-            cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
-         }
-         else 
-#endif
-         {
          /* If MSG4 is pending for this UE, schedule PDCCH,PDSCH to send MSG4 and
           * PUCCH to receive UL msg as per k0-k1 configuration  */
          if (cell->ueCb[ueId-1].retxMsg4HqProc) //should work from dlmap later tbd
@@ -909,78 +900,77 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
             }
          }
 
-         /* DL Data */
-         node = cell->ueCb[ueId-1].dlRetxHqList.first;
-         if(node != NULLP)
+#ifdef NR_DRX 
+         if((cell->ueCb[ueId-1].ueDrxInfoPres == true) && (cell->ueCb[ueId-1].drxUeCb.drxDlUeActiveStatus != true))
          {
-            /* DL Data ReTransmisson */
-            isDlMsgPending = true;
-            isDlMsgScheduled = schFillBoGrantDlSchedInfo(cell, *slotInd, ueId, TRUE, ((SchDlHqProcCb**) &(node->node)));
-            cmLListDelFrm(&cell->ueCb[ueId-1].dlRetxHqList, node);
+            if(pendingUeNode->node)
+            {
+               cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
+            }
          }
-         else
+         else 
+#endif
          {
-            /* DL Data new transmission */
-            if((cell->boIndBitMap) & (1<<ueId))
+            
+            /* DL Data */
+            node = cell->ueCb[ueId-1].dlRetxHqList.first;
+            if(node != NULLP)
             {
-               isDlMsgPending = true;               
-               isDlMsgScheduled = schFillBoGrantDlSchedInfo(cell, *slotInd, ueId, FALSE, &hqP);
-
-               /* If DL scheduling failed, free the newly assigned HARQ process */
-               if(!isDlMsgScheduled)
-                  schDlReleaseHqProcess(hqP);
-               else
+               /* DL Data ReTransmisson */
+               isDlMsgPending = true;
+               isDlMsgScheduled = schFillBoGrantDlSchedInfo(cell, *slotInd, ueId, TRUE, ((SchDlHqProcCb**) &(node->node)));
+               cmLListDelFrm(&cell->ueCb[ueId-1].dlRetxHqList, node);
+            }
+            else
+            {
+               /* DL Data new transmission */
+               if((cell->boIndBitMap) & (1<<ueId))
                {
-#ifdef NR_DRX 
-                  if(cell->ueCb[ueId-1].ueDrxInfoPres)
-                     schHdlDrxInActvStrtTmr(cell, &cell->ueCb[ueId-1], PHY_DELTA_DL + SCHED_DELTA);
-#endif               
+                  isDlMsgPending = true;               
+                  isDlMsgScheduled = schFillBoGrantDlSchedInfo(cell, *slotInd, ueId, FALSE, &hqP);
+
+                  /* If DL scheduling failed, free the newly assigned HARQ process */
+                  if(!isDlMsgScheduled)
+                     schDlReleaseHqProcess(hqP);
                }
             }
-         }
 
-         /* Scheduling of UL grant */
-         node = cell->ueCb[ueId-1].ulRetxHqList.first;
-         if(node != NULLP)
-         {
-            /* UL Data ReTransmisson */
-            isUlGrantPending = true;
-            isUlGrantScheduled = schProcessSrOrBsrReq(cell, *slotInd, ueId, TRUE, (SchUlHqProcCb**) &(node->node));
-            cmLListDelFrm(&cell->ueCb[ueId-1].ulRetxHqList, node);
-         }
-         else
-         {
-            /* UL Data new transmission */
-            if(cell->ueCb[ueId-1].srRcvd || cell->ueCb[ueId-1].bsrRcvd)
+            /* Scheduling of UL grant */
+            node = cell->ueCb[ueId-1].ulRetxHqList.first;
+            if(node != NULLP)
             {
+               /* UL Data ReTransmisson */
                isUlGrantPending = true;
-               isUlGrantScheduled = schProcessSrOrBsrReq(cell, *slotInd, ueId, FALSE, &ulHqP);
-               if(!isUlGrantScheduled)
-                  schUlReleaseHqProcess(ulHqP, FALSE);
-               else
+               isUlGrantScheduled = schProcessSrOrBsrReq(cell, *slotInd, ueId, TRUE, (SchUlHqProcCb**) &(node->node));
+               cmLListDelFrm(&cell->ueCb[ueId-1].ulRetxHqList, node);
+            }
+            else
+            {
+               /* UL Data new transmission */
+               if(cell->ueCb[ueId-1].srRcvd || cell->ueCb[ueId-1].bsrRcvd)
                {
-#ifdef NR_DRX 
-                  if(cell->ueCb[ueId-1].ueDrxInfoPres)
-                     schHdlDrxInActvStrtTmr(cell, &cell->ueCb[ueId-1], PHY_DELTA_UL + SCHED_DELTA);
-#endif               
+                  isUlGrantPending = true;
+                  isUlGrantScheduled = schProcessSrOrBsrReq(cell, *slotInd, ueId, FALSE, &ulHqP);
+                  if(!isUlGrantScheduled)
+                     schUlReleaseHqProcess(ulHqP, FALSE);
                }
             }
-         }
 
-         if(!isUlGrantPending && !isDlMsgPending)
-         {
-            /* No action required */  
-         }
-         else if((isUlGrantPending && !isUlGrantScheduled) || (isDlMsgPending && !isDlMsgScheduled))
-         {
-            cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
-         }
-         else
-         {
-            SCH_FREE(ueNode, sizeof(uint8_t));
-            deleteNodeFromLList(&cell->ueToBeScheduled, pendingUeNode);
+            if(!isUlGrantPending && !isDlMsgPending)
+            {
+               /* No action required */  
+            }
+            else if((isUlGrantPending && !isUlGrantScheduled) || (isDlMsgPending && !isDlMsgScheduled))
+            {
+               cmLListAdd2Tail(&cell->ueToBeScheduled, cmLListDelFrm(&cell->ueToBeScheduled, pendingUeNode));
+            }
+            else
+            {
+               SCH_FREE(ueNode, sizeof(uint8_t));
+               deleteNodeFromLList(&cell->ueToBeScheduled, pendingUeNode);
+            }
          }
-      }}
+      }
    }
 
    /* Check if any PDU is scheduled at this slot for any UE */