Fixed issues in processing of large DL packets [Issue-ID: ODUHIGH-309]
[o-du/l2.git] / src / 5gnrsch / sch_slot_ind.c
index 9864701..3a23293 100644 (file)
@@ -49,8 +49,8 @@ SchMacDlAllocFunc schMacDlAllocOpts[] =
    packSchMacDlAlloc
 };
 
-extern SchCb schCb[SCH_MAX_INST];
-extern int schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t
+SchCb schCb[SCH_MAX_INST];
+int schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t
       offsetPointA);
 
 /*******************************************************************
@@ -140,7 +140,7 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
    uint8_t ueIdx, lcIdx;
    uint16_t slot;
    uint16_t crnti = 0;
-   uint16_t accumalatedSize = 0;
+   uint32_t accumalatedSize = 0;
    SchUeCb *ueCb = NULLP;
 
    while(cell->boIndBitMap)
@@ -155,7 +155,7 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
       SCH_ALLOC(dlMsgAlloc, sizeof(DlMsgAlloc));
       if(!dlMsgAlloc)
       {
-        DU_LOG("\nMAC: Memory Allocation failed for ded DL msg alloc");
+        DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for ded DL msg alloc");
         return RFAILED;
       }
       memset(dlMsgAlloc, 0, sizeof(DlMsgAlloc));
@@ -176,7 +176,7 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
 
            /* calculation for BO includse RLC and MAC header size */
            dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].schBytes = \
-              ueCb->dlInfo.dlLcCtxt[lcIdx].bo + RLC_HDR_SIZE + MAC_HDR_SIZE;
+              ueCb->dlInfo.dlLcCtxt[lcIdx].bo + MAC_HDR_SIZE;
            accumalatedSize += dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc].schBytes;
            dlMsgAlloc->numLc++;
         }
@@ -184,7 +184,13 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
       }
 
       /* pdcch and pdsch data is filled */
-      schDlRsrcAllocDlMsg(dlMsgAlloc, cell, crnti, accumalatedSize, slot);
+      schDlRsrcAllocDlMsg(dlMsgAlloc, cell, crnti, &accumalatedSize, slot);
+      /* Calculated TB size could be less than the total size requested.
+       * Hence, updated the scheduled bytes report. Following is valid only for
+       * one LC.
+       * TODO : Update the scheduling byte report for multiple LC based on QCI
+       * and Priority */
+      dlMsgAlloc->lcSchInfo[dlMsgAlloc->numLc -1].schBytes = accumalatedSize;
 
       /* PUCCH resource */
       schAllocPucchResource(cell, dlMsgAlloc->crnti, slot);
@@ -240,8 +246,8 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
    memcpy(&cell->slotInfo, slotInd, sizeof(SlotIndInfo));
    dlBrdcstAlloc->ssbIdxSupported = 1;
 
-   sfnSlot = ((dlSchedInfo.schSlotValue.broadcastTime.sfn * 10) +
-        dlSchedInfo.schSlotValue.broadcastTime.slot);
+   sfnSlot = dlSchedInfo.schSlotValue.broadcastTime.sfn * cell->numSlots +
+      dlSchedInfo.schSlotValue.broadcastTime.slot;
 
    slot = dlSchedInfo.schSlotValue.currentTime.slot;
 
@@ -251,8 +257,10 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
    if (sfnSlot % SCH_MIB_TRANS == 0)
    {
       dlBrdcstAlloc->ssbTrans = SSB_TRANSMISSION;
+      if(!cell->firstSsbTransmitted)
+         cell->firstSsbTransmitted = true;
    }
-   else if (sfnSlot % ssb_rep == 0)
+   else if (cell->firstSsbTransmitted && (sfnSlot % ssb_rep == 0))
    {
       dlBrdcstAlloc->ssbTrans = SSB_REPEAT;
    }
@@ -265,8 +273,10 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
    if(sfnSlot % cell->cellCfg.sib1SchCfg.sib1NewTxPeriod == 0)
    {
       dlBrdcstAlloc->sib1Trans = SIB1_TRANSMISSION;
+      if(!cell->firstSib1Transmitted)
+         cell->firstSib1Transmitted = true;
    }
-   else if (sfnSlot % cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod == 0)
+   else if (cell->firstSib1Transmitted && (sfnSlot % cell->cellCfg.sib1SchCfg.sib1RepetitionPeriod == 0))
    {
       dlBrdcstAlloc->sib1Trans = SIB1_REPITITION;
    }
@@ -282,7 +292,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
       ret = schBroadcastAlloc(cell,dlBrdcstAlloc,slot);
       if(ret != ROK)
       {
-        DU_LOG("\nschBroadcastAlloc failed");
+        DU_LOG("\nERROR  -->  SCH : schBroadcastAlloc failed");
         return (ret);
       }
    }
@@ -294,7 +304,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
       SCH_ALLOC(rarAlloc, sizeof(RarAlloc));
       if(!rarAlloc)
       {
-        DU_LOG("\nMAC: Memory Allocation failed for RAR alloc");
+        DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for RAR alloc");
         return RFAILED;
       }
 
@@ -322,7 +332,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
       SCH_ALLOC(msg4Alloc, sizeof(DlMsgAlloc));
       if(!msg4Alloc)
       {
-        DU_LOG("\nMAC: Memory Allocation failed for msg4 alloc");
+        DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for msg4 alloc");
         return RFAILED;
       }
 
@@ -369,7 +379,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
         SCH_ALLOC(dciInfo, sizeof(DciInfo));
         if(!dciInfo)
         {
-           DU_LOG("\nMAC: Memory Allocation failed for dciInfo alloc");
+           DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for dciInfo alloc");
            return RFAILED;
         }
         memset(dciInfo,0,sizeof(DciInfo));
@@ -396,7 +406,7 @@ uint8_t schProcessSlotInd(SlotIndInfo *slotInd, Inst schInst)
    ret = sendDlAllocToMac(&dlSchedInfo, schInst);
    if(ret != ROK)
    {
-      DU_LOG("\nSending DL Broadcast allocation from SCH to MAC failed");
+      DU_LOG("\nERROR  -->  SCH : Sending DL Broadcast allocation from SCH to MAC failed");
       return (ret);
    }