JIRA ID: ODUHIGH-381 : DL packets Scheduling as per RRM Policy
[o-du/l2.git] / src / 5gnrsch / sch_rach.c
index 9f37d1c..e1b9619 100644 (file)
 #include "sch.h"
 #include "sch_utils.h"
 
-SchCb schCb[SCH_MAX_INST];
-uint8_t puschDeltaTable[MAX_MU_PUSCH];
+/**
+ * @brief Checks if PRACH can be scheduled in current slot
+ *
+ * @details
+ *
+ *     Function : schCheckPrachOcc
+ *
+ *     This function checks if PRACH can be scheduled in 
+ *     current slot
+ *
+ *  @param[in]  Cell Cb
+ *              Slot timing
+ *  @return  TRUE
+ *           FALSE
+ **/
+bool schCheckPrachOcc(SchCellCb *cell, SlotTimingInfo prachOccasionTimingInfo)
+{
+   uint8_t  prachCfgIdx = 0;
+   uint8_t  x = 0;
+   uint8_t  y = 0;
+   uint8_t  subFrame = 0;
+   uint16_t prachSubframe = 0;
+
+   prachCfgIdx      = cell->cellCfg.schRachCfg.prachCfgIdx;
+
+   /* derive the prachCfgIdx table paramters */
+   x                = prachCfgIdxTable[prachCfgIdx][1];
+   y                = prachCfgIdxTable[prachCfgIdx][2];
+   prachSubframe    = prachCfgIdxTable[prachCfgIdx][3];
+
+   if((prachOccasionTimingInfo.sfn%x) == y)
+   {
+      subFrame = prachOccasionTimingInfo.slot/pow(2, cell->cellCfg.numerology);
+
+      /* check for subFrame number */
+      if ((1 << subFrame) & prachSubframe)
+      {
+         /* prach ocassion present in this subframe */
+#ifdef NR_TDD
+         if(UL_SLOT != schGetSlotSymbFrmt(prachOccasionTimingInfo.slot % cell->numSlotsInPeriodicity,\
+         cell->slotFrmtBitMap))
+         {
+            DU_LOG("\nERROR  --> SCH : PrachCfgIdx %d doesn't support UL slot", prachCfgIdx);
+            return FALSE;
+         }
+#endif
+         return TRUE;
+      }
+   }
+   return FALSE;
+}
+
+/**
+ * @brief Calculate number of PRBs to be allocated for PRACH 
+ *
+ * @details
+ *
+ *     Function : schCalcPrachNumRb
+ *
+ *     Calculate number of PRBs to be allocated for PRACH
+ *
+ *  @param[in]  SchCellCb *cell, cell cb
+ *  @return  Number of PRBs
+ **/
+uint8_t schCalcPrachNumRb(SchCellCb *cell)
+{
+   uint8_t tableIdx = 0;
+   uint16_t puschScs = fetchScsValue(cell->cellCfg.schInitialUlBwp.bwp.scs);
+
+   for(tableIdx=0; tableIdx < MAX_RACH_NUM_RB_IDX; tableIdx++)
+   {
+      if((numRbForPrachTable[tableIdx][0] == cell->cellCfg.schRachCfg.rootSeqLen) &&
+            (numRbForPrachTable[tableIdx][1] == cell->cellCfg.schRachCfg.prachSubcSpacing) &&
+            (numRbForPrachTable[tableIdx][2] == puschScs))
+      {
+         return numRbForPrachTable[tableIdx][3];
+      }
+   }
+   return 0;
+}
+
+/**
+ * @brief resource allocation for PRACH
+ *
+ * @details
+ *
+ *     Function : schPrachResAlloc
+ *
+ *     This function handles PRACH allocation
+ *
+ *  @param[in]  SchCellCb *cell, cell cb
+ *  @param[in]  UlSchedInfo *ulSchedInfo, UL scheduling info
+ *  @return  void
+ **/
+void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotTimingInfo prachOccasionTimingInfo)
+{
+   uint8_t  numPrachRb = 0;
+   uint8_t  numRa = 0;
+   uint8_t  prachCfgIdx = 0;
+   uint8_t  prachFormat = 0;
+   uint8_t  prachStartSymbol = 0;
+   uint8_t  prachDuration = 0;
+   uint8_t  prachOcas = 0;
+   uint8_t  dataType = 0;
+   uint16_t freqStart = 0;
+
+   /* If this slot is not a PRACH occassion, return */
+   if(!schCheckPrachOcc(cell, prachOccasionTimingInfo))
+      return;
+
+   prachCfgIdx      = cell->cellCfg.schRachCfg.prachCfgIdx;
+   prachFormat      = prachCfgIdxTable[prachCfgIdx][0];
+   prachStartSymbol = prachCfgIdxTable[prachCfgIdx][4];
+   prachOcas        = prachCfgIdxTable[prachCfgIdx][6];
+   prachDuration    = prachCfgIdxTable[prachCfgIdx][7];
+
+   /* numRa determined as 𝑛 belonging {0,1,.., M − 1},
+    * where M is given by msg1Fdm */
+   numRa = (cell->cellCfg.schRachCfg.msg1Fdm - 1);
+
+   /* freq domain resource determination for RACH*/
+   freqStart = cell->cellCfg.schRachCfg.msg1FreqStart;
+   numPrachRb = schCalcPrachNumRb(cell);
+   /* Allocate PRACH resources from the UL resource bitmap */
+   allocatePrbUl(cell, prachOccasionTimingInfo, prachStartSymbol, prachDuration, &freqStart, numPrachRb);
+
+   /* prach info */
+   dataType |= SCH_DATATYPE_PRACH;
+   ulSchedInfo->dataType = dataType;
+   ulSchedInfo->prachSchInfo.numPrachOcas   = prachOcas;
+   ulSchedInfo->prachSchInfo.prachFormat    = prachFormat;
+   ulSchedInfo->prachSchInfo.numRa          = numRa;
+   ulSchedInfo->prachSchInfo.prachStartSymb = prachStartSymbol;
+   DU_LOG("\nINFO  --> SCH : RACH occassion set for slot %d", prachOccasionTimingInfo.slot);
+}
 
 /**
  * @brief calculate ra-rnti function. 
@@ -105,53 +238,47 @@ void createSchRaCb(uint16_t tcrnti, Inst schInst)
  *  @param[out]  msg3NumRb
  *  @return  void
  **/
-SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t crnti, uint8_t k2Index, uint16_t msg3Slot)
+SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t crnti, uint8_t k2Index, SlotTimingInfo msg3SlotTime)
 {
    SchCellCb      *cell          = NULLP;
    SchUlSlotInfo  *schUlSlotInfo = NULLP;
-   uint8_t    startSymb     = 0;
-   uint8_t    symbLen       = 0; 
-   uint8_t    startRb       = 0;
-   uint8_t    numRb         = 0;
-   uint8_t    idx           = 0;
-   uint8_t    mcs            = 4;
-   uint8_t    numPdschSymbols= 11;
-   uint16_t   tbSize         = 0;
+   uint8_t    mcs       = DEFAULT_MCS;
+   uint8_t    startSymb = 0;
+   uint8_t    symbLen   = 0; 
+   uint16_t   startRb   = 0;
+   uint16_t   numRb     = 0;
+   uint16_t   tbSize    = 0;
 
    cell = schCb[schInst].cells[schInst];
    if(cell == NULL)
    {
       DU_LOG("\n\nERROR  -->  SCH :  Failed to find cell in schAllocMsg3Pusch");
-      return RFAILED;
+      return NULLP;
    }
 
+   /* Allocate time-domain and frequency-domain resource for MSG3 PUSCH */
    startSymb = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].startSymbol;
    symbLen = cell->cellCfg.schInitialUlBwp.puschCommon.timeDomRsrcAllocList[k2Index].symbolLength;
 
-   startRb = cell->schUlSlotInfo[msg3Slot]->puschCurrentPrb;
-   tbSize = schCalcTbSize(8); /* 6 bytes msg3  and 2 bytes header */
-   numRb = schCalcNumPrb(tbSize, mcs, numPdschSymbols);
-
-   /* allocating 1 extra RB for now */
-   numRb++;
-   /* increment PUSCH PRB */
-   cell->schUlSlotInfo[msg3Slot]->puschCurrentPrb += numRb;
-
-   for(idx=startSymb; idx<symbLen; idx++)
-   {
-      cell->schUlSlotInfo[msg3Slot]->assignedPrb[idx] = startRb + numRb;
-   }
-   schUlSlotInfo = cell->schUlSlotInfo[msg3Slot];
+   startRb = MAX_NUM_RB;
+   tbSize = schCalcTbSize(8); /* 6 bytes msg3 and 2 bytes header */
+   numRb = schCalcNumPrb(tbSize, mcs, symbLen);
+   numRb++; /* allocating 1 extra RB for now */
+   allocatePrbUl(cell, msg3SlotTime, startSymb, symbLen, &startRb, numRb);
 
+   /* Fill PUSCH scheduling details in Slot structure */
+   schUlSlotInfo = cell->schUlSlotInfo[msg3SlotTime.slot];
    SCH_ALLOC(schUlSlotInfo->schPuschInfo, sizeof(SchPuschInfo));
    if(!schUlSlotInfo->schPuschInfo)
    {
       DU_LOG("\nERROR  -->  SCH :  Memory allocation failed in schAllocMsg3Pusch");
       return NULLP;
    }
+
    tbSize = 0;  /* since nPrb has been incremented, recalculating tbSize */
-   tbSize = schCalcTbSizeFromNPrb(numRb, mcs, numPdschSymbols);
+   tbSize = schCalcTbSizeFromNPrb(numRb, mcs, NUM_PDSCH_SYMBOL);
    tbSize = tbSize / 8 ; /*bits to byte conversion*/
+
    schUlSlotInfo->schPuschInfo->crnti             = crnti;
    schUlSlotInfo->schPuschInfo->harqProcId        = SCH_HARQ_PROC_ID;
    schUlSlotInfo->schPuschInfo->resAllocType      = SCH_ALLOC_TYPE_1;
@@ -164,7 +291,7 @@ SchPuschInfo* schAllocMsg3Pusch(Inst schInst, uint16_t crnti, uint8_t k2Index, u
    schUlSlotInfo->schPuschInfo->tbInfo.mcsTable   = SCH_MCS_TABLE_QAM_64;
    schUlSlotInfo->schPuschInfo->tbInfo.ndi        = NEW_TRANSMISSION; /* new transmission */
    schUlSlotInfo->schPuschInfo->tbInfo.rv              = 0;
-   schUlSlotInfo->schPuschInfo->tbInfo.tbSize     = tbSize; /*Considering 2 PRBs */
+   schUlSlotInfo->schPuschInfo->tbInfo.tbSize     = tbSize;
    schUlSlotInfo->schPuschInfo->dmrsMappingType   = DMRS_MAP_TYPE_A;  /* Setting Type-A */
    schUlSlotInfo->schPuschInfo->nrOfDmrsSymbols   = NUM_DMRS_SYMBOLS;
    schUlSlotInfo->schPuschInfo->dmrsAddPos        = DMRS_ADDITIONAL_POS;
@@ -227,15 +354,14 @@ void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cell)
 #ifdef NR_TDD
    uint8_t   totalCfgSlot = 0;
 #endif
-   uint16_t  dciSlot = 0, rarSlot = 0, msg3Slot = 0;
-   SlotTimingInfo dciTime, rarTime;
-   RarAlloc *dciSlotAlloc = NULLP;  /* Stores info for transmission of PDCCH for RAR */
-   RarAlloc *rarSlotAlloc = NULLP;  /* Stores info for transmission of RAR PDSCH */
-   SchPuschInfo *msg3PuschInfo = NULLP;          /* Stores MSG3 PUSCH scheduling information */
-   PduTxOccsaion  ssbOccasion=0, sib1Occasion=0;
+   uint16_t             dciSlot = 0, rarSlot = 0;
+   SlotTimingInfo       dciTime, rarTime, msg3Time;
+   RarAlloc             *dciSlotAlloc = NULLP;    /* Stores info for transmission of PDCCH for RAR */
+   RarAlloc             *rarSlotAlloc = NULLP;    /* Stores info for transmission of RAR PDSCH */
+   SchPuschInfo         *msg3PuschInfo = NULLP;   /* Stores MSG3 PUSCH scheduling information */
    SchK0K1TimingInfoTbl *k0K1InfoTbl=NULLP;    
-   SchK2TimingInfoTbl *msg3K2InfoTbl=NULLP;
-   RaRspWindowStatus windowStatus=0;
+   SchK2TimingInfoTbl   *msg3K2InfoTbl=NULLP;
+   RaRspWindowStatus    windowStatus=0;
 
    while(ueIdx < MAX_NUM_UE)
    {
@@ -289,9 +415,9 @@ void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cell)
                   k2 = k2 + msg3Delta;
                   if(k2 >= msg3MinSchTime)
                   {
-                     msg3Slot = (rarSlot + k2) % cell->numSlots;
+                     ADD_DELTA_TO_TIME(rarTime, msg3Time, k2);
 #ifdef NR_TDD
-                     if(schGetSlotSymbFrmt(msg3Slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT)
+                     if(schGetSlotSymbFrmt(msg3Time.slot % totalCfgSlot, cell->slotFrmtBitMap) == DL_SLOT)
                         continue;
 #endif
                      k2Found = true;
@@ -326,17 +452,17 @@ void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cell)
          }
          cell->schDlSlotInfo[dciSlot]->rarAlloc = dciSlotAlloc;
 
-         /* Check if RAR PDSCH occasion same as SSB and SIB1 occasion */
-         ssbOccasion = schCheckSsbOcc(rarTime, cell);
-         sib1Occasion = schCheckSib1Occ(rarTime, cell);
-
          /* Fill PDCCH and PDSCH scheduling information for RAR */
-         schFillRar(dciSlotAlloc, cell->raReq[ueIdx]->raRnti,
-            cell->cellCfg.phyCellId, cell->cellCfg.ssbSchCfg.ssbOffsetPointA, k0Index,
-            ssbOccasion, sib1Occasion);
+         if((schFillRar(cell, rarTime, ueIdx, dciSlotAlloc, k0Index)) != ROK)
+         {
+            DU_LOG("\nERROR  -->  SCH: Scheduling of RAR failed in slot [%d]", rarSlot);
+            SCH_FREE(dciSlotAlloc, sizeof(RarAlloc));
+            cell->schDlSlotInfo[dciSlot]->rarAlloc = NULLP;
+            return;
+         }
 
          /* Allocate resources for msg3 */
-         msg3PuschInfo = schAllocMsg3Pusch(cell->instIdx, cell->raReq[ueIdx]->rachInd->crnti, k2Index, msg3Slot);
+         msg3PuschInfo = schAllocMsg3Pusch(cell->instIdx, cell->raReq[ueIdx]->rachInd->crnti, k2Index, msg3Time);
          if(msg3PuschInfo)
          {
             /* Fill RAR info */
@@ -370,6 +496,7 @@ void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cell)
             {
                DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for rarSlotAlloc");
                SCH_FREE(dciSlotAlloc, sizeof(RarAlloc));
+               cell->schDlSlotInfo[dciSlot]->rarAlloc = NULLP;
                return;
             }
             cell->schDlSlotInfo[rarSlot]->rarAlloc = rarSlotAlloc;
@@ -470,42 +597,29 @@ uint8_t schProcessRachInd(RachIndInfo *rachInd, Inst schInst)
  *  @param[in]  offset to pointA to determine freq alloc
  *  @return  ROK
  **/
-uint8_t schFillRar(RarAlloc *rarAlloc, uint16_t raRnti, uint16_t pci, uint8_t offsetPointA, \
-uint8_t k0Index, bool ssbPresent, bool sib1Present)
+uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueIdx, RarAlloc *rarAlloc, uint8_t k0Index)
 {
-   Inst inst = 0;
-   uint8_t coreset0Idx = 0;
-   uint8_t numRbs = 0;
-   uint8_t firstSymbol = 0;
-   uint8_t numSymbols = 0;
-   uint8_t offset = 0;
-   uint8_t FreqDomainResource[6] = {0};
+   uint8_t  coreset0Idx = 0;
+   uint8_t  firstSymbol = 0, numSymbols = 0;
+   uint8_t  mcs = DEFAULT_MCS;  /* MCS fixed to 4 */
+   uint8_t  dmrsStartSymbol, startSymbol, numSymbol ;
+   uint16_t numRbs = 0;
    uint16_t tbSize = 0;
-   uint8_t mcs = 4;  /* MCS fixed to 4 */
-
-   if(schCb[inst].cells[inst] == NULL)
-   {
-      DU_LOG("\nERROR  -->  SCH: Cell not found");
-      return RFAILED;
-   }
 
-   SchBwpDlCfg *initialBwp = &schCb[inst].cells[inst]->cellCfg.schInitialDlBwp;
+   SchBwpDlCfg *initialBwp = &cell->cellCfg.schInitialDlBwp;
    PdcchCfg *pdcch = &rarAlloc->rarPdcchCfg;
    PdschCfg *pdsch = &rarAlloc->rarPdschCfg;
    BwpCfg *bwp = &rarAlloc->bwp;
-   FreqDomainAlloc *sib1PdschFreqAlloc = NULL;
-
-   coreset0Idx     = initialBwp->pdcchCommon.commonSearchSpace.coresetId;
 
    /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
-   numRbs        = coresetIdxTable[coreset0Idx][1];
-   numSymbols    = coresetIdxTable[coreset0Idx][2];
-   offset        = coresetIdxTable[coreset0Idx][3];
+   coreset0Idx     = initialBwp->pdcchCommon.commonSearchSpace.coresetId;
+   numRbs     = coresetIdxTable[coreset0Idx][1]; 
+   numSymbols = coresetIdxTable[coreset0Idx][2];
 
    /* calculate time domain parameters */
    // note: since slot value is made sl1, RAR can be sent at all slots
    uint16_t mask = 0x2000;
-   for(firstSymbol=0; firstSymbol<14;firstSymbol++)
+   for(firstSymbol=0; firstSymbol<MAX_SYMB_PER_SLOT; firstSymbol++)
    {
       if(initialBwp->pdcchCommon.commonSearchSpace.monitoringSymbol & mask)
         break;
@@ -513,9 +627,6 @@ uint8_t k0Index, bool ssbPresent, bool sib1Present)
         mask = mask>>1;
    }
 
-   /* calculate the PRBs */
-   freqDomRscAllocType0(((offsetPointA-offset)/6), (numRbs/6), FreqDomainResource);
-
    /* fill BWP */
    bwp->freqAlloc.numPrb   = initialBwp->bwp.freqAlloc.numPrb;
    bwp->freqAlloc.startPrb = initialBwp->bwp.freqAlloc.startPrb;
@@ -525,16 +636,19 @@ uint8_t k0Index, bool ssbPresent, bool sib1Present)
    /* fill the PDCCH PDU */
    pdcch->coresetCfg.startSymbolIndex = firstSymbol;
    pdcch->coresetCfg.durationSymbols = numSymbols;
-   memcpy(pdcch->coresetCfg.freqDomainResource, FreqDomainResource, FREQ_DOM_RSRC_SIZE);
+   memcpy(pdcch->coresetCfg.freqDomainResource, \
+      cell->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
+
    pdcch->coresetCfg.cceRegMappingType = 1; /* coreset0 is always interleaved */
    pdcch->coresetCfg.regBundleSize = 6;    /* spec-38.211 sec 7.3.2.2 */
    pdcch->coresetCfg.interleaverSize = 2;  /* spec-38.211 sec 7.3.2.2 */
    pdcch->coresetCfg.coreSetType = 0;
-   pdcch->coresetCfg.shiftIndex = pci;
+   pdcch->coresetCfg.coreSetSize = numRbs;
+   pdcch->coresetCfg.shiftIndex = cell->cellCfg.phyCellId;
    pdcch->coresetCfg.precoderGranularity = 0; /* sameAsRegBundle */
    pdcch->numDlDci = 1;
-   pdcch->dci.rnti = raRnti; /* RA-RNTI */
-   pdcch->dci.scramblingId = pci;
+   pdcch->dci.rnti = cell->raReq[ueIdx]->raRnti; /* RA-RNTI */
+   pdcch->dci.scramblingId = cell->cellCfg.phyCellId;
    pdcch->dci.scramblingRnti = 0;
    pdcch->dci.cceIndex = 4; /* considering SIB1 is sent at cce 0-1-2-3 */
    pdcch->dci.aggregLevel = 4;
@@ -550,7 +664,7 @@ uint8_t k0Index, bool ssbPresent, bool sib1Present)
    /* fill the PDSCH PDU */
    uint8_t cwCount = 0;
    pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
-   pdsch->rnti = raRnti; /* RA-RNTI */
+   pdsch->rnti = cell->raReq[ueIdx]->raRnti; /* RA-RNTI */
    pdsch->pduIndex = 0;
    pdsch->numCodewords = 1;
    for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
@@ -564,38 +678,53 @@ uint8_t k0Index, bool ssbPresent, bool sib1Present)
       tbSize = schCalcTbSize(RAR_PAYLOAD_SIZE + TX_PAYLOAD_HDR_LEN);
       pdsch->codeword[cwCount].tbSize = tbSize;
    }
-   pdsch->dataScramblingId = pci;
+   pdsch->dataScramblingId = cell->cellCfg.phyCellId;
    pdsch->numLayers = 1;
    pdsch->transmissionScheme = 0;
    pdsch->refPoint = 0;
    pdsch->dmrs.dlDmrsSymbPos = 4;  /* Bitmap value 00000000000100 i.e. using 3rd symbol for PDSCH DMRS */
    pdsch->dmrs.dmrsConfigType = 0; /* type-1 */
-   pdsch->dmrs.dlDmrsScramblingId = pci;
+   pdsch->dmrs.dlDmrsScramblingId = cell->cellCfg.phyCellId;
    pdsch->dmrs.scid = 0;
    pdsch->dmrs.numDmrsCdmGrpsNoData = 1;
    pdsch->dmrs.dmrsPorts = 0;
    pdsch->dmrs.mappingType      = DMRS_MAP_TYPE_A;  /* Type-A */
    pdsch->dmrs.nrOfDmrsSymbols  = NUM_DMRS_SYMBOLS;
    pdsch->dmrs.dmrsAddPos       = DMRS_ADDITIONAL_POS;
+
+   pdsch->pdschTimeAlloc.timeAlloc.startSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol;
+   pdsch->pdschTimeAlloc.timeAlloc.numSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol;
+
+   pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */
    pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */
-   /* The RB numbering starts from coreset0 */ 
-   pdsch->pdschFreqAlloc.freqAlloc.startPrb = PDSCH_START_RB;
-   if(ssbPresent)
+   pdsch->pdschFreqAlloc.freqAlloc.startPrb = MAX_NUM_RB;
+   pdsch->pdschFreqAlloc.freqAlloc.numPrb = \
+      schCalcNumPrb(tbSize, mcs, initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol);
+
+   /* Find total symbols occupied including DMRS */
+   dmrsStartSymbol = findDmrsStartSymbol(pdsch->dmrs.dlDmrsSymbPos);
+   /* If there are no DRMS symbols, findDmrsStartSymbol() returns MAX_SYMB_PER_SLOT, 
+    * in that case only PDSCH symbols are marked as occupied */
+   if(dmrsStartSymbol == MAX_SYMB_PER_SLOT)
    {
-      /* PDSCH is always above SSB */
-      pdsch->pdschFreqAlloc.freqAlloc.startPrb = offsetPointA + SCH_SSB_NUM_PRB + 1;
+      startSymbol = pdsch->pdschTimeAlloc.timeAlloc.startSymb;
+      numSymbol = pdsch->pdschTimeAlloc.timeAlloc.numSymb;
    }
-   if(sib1Present)
+   /* If DMRS symbol is found, mark DMRS and PDSCH symbols as occupied */
+   else
    {
-      /* Must not overlap with SIB1 */
-      sib1PdschFreqAlloc = &schCb[inst].cells[inst]->cellCfg.sib1SchCfg.sib1PdschCfg.pdschFreqAlloc.freqAlloc;
-      pdsch->pdschFreqAlloc.freqAlloc.startPrb = sib1PdschFreqAlloc->startPrb + sib1PdschFreqAlloc->numPrb + 1; 
+      startSymbol = dmrsStartSymbol;
+      numSymbol = pdsch->dmrs.nrOfDmrsSymbols + pdsch->pdschTimeAlloc.timeAlloc.numSymb;
    }
-   pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, \
-      initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol);
-   pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */
-   pdsch->pdschTimeAlloc.timeAlloc.startSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].startSymbol;
-   pdsch->pdschTimeAlloc.timeAlloc.numSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Index].lengthSymbol;
+
+   /* Allocate the number of PRBs required for RAR PDSCH */
+   if((allocatePrbDl(cell, rarTime, startSymbol, numSymbol,\
+      &pdsch->pdschFreqAlloc.freqAlloc.startPrb, pdsch->pdschFreqAlloc.freqAlloc.numPrb)) != ROK)
+   {
+      DU_LOG("\nERROR  --> SCH : allocatePrbDl() failed for RAR");
+      return RFAILED;
+   }
+
    pdsch->beamPdschInfo.numPrgs = 1;
    pdsch->beamPdschInfo.prgSize = 1;
    pdsch->beamPdschInfo.digBfInterfaces = 0;