MSG4 scheduling based on k0-k1 [Issue-ID: ODUHIGH-388] 61/6961/5
authorlal.harshita <Harshita.Lal@radisys.com>
Thu, 28 Oct 2021 12:00:47 +0000 (17:30 +0530)
committerlal.harshita <Harshita.Lal@radisys.com>
Fri, 29 Oct 2021 15:18:13 +0000 (20:48 +0530)
Change-Id: I97491356b0eb1f4cd63e416c9c3daa2468feb8ea
Signed-off-by: lal.harshita <Harshita.Lal@radisys.com>
src/5gnrmac/lwr_mac_fsm.c
src/5gnrsch/sch.c
src/5gnrsch/sch.h
src/5gnrsch/sch_common.c
src/5gnrsch/sch_rach.c
src/5gnrsch/sch_slot_ind.c
src/5gnrsch/sch_ue_mgr.c
src/cm/mac_sch_interface.h

index 6f4f8a8..686d3fa 100644 (file)
@@ -3108,7 +3108,11 @@ uint8_t calcDlTtiReqPduCount(DlSchedInfo *dlInfo)
    if(dlInfo->dlMsgAlloc != NULLP)
    {
       /* PDCCH and PDSCH PDU is filled */
-      count += 2;
+      if(dlInfo->dlMsgAlloc->pduPres == BOTH)
+         count += 2;
+      else
+         count += 1;
+
    }
    return count;
 }
@@ -3142,7 +3146,8 @@ uint8_t calcTxDataReqPduCount(DlSchedInfo *dlInfo)
    }
    if(dlInfo->dlMsgAlloc != NULLP)
    {
-      count++;
+      if(dlInfo->dlMsgAlloc->pduPres == BOTH || dlInfo->dlMsgAlloc->pduPres == PDSCH_PDU)
+         count++;
    }
    return count;
 }
@@ -3484,31 +3489,44 @@ uint16_t fillDlTtiReq(SlotTimingInfo currTimingInfo)
                if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.dlMsgPdu != NULLP)
                {
                   /* Filling Msg4 param */
-                  DU_LOG("\033[1;32m");
-                  if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.isMsg4Pdu)
+                  if((currDlSlot->dlInfo.dlMsgAlloc->pduPres == BOTH) || \
+                  (currDlSlot->dlInfo.dlMsgAlloc->pduPres == PDCCH_PDU))
                   {
-                     rntiType = TC_RNTI_TYPE;
-                     fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
-                           &currDlSlot->dlInfo, rntiType, CORESET_TYPE0);
-                     DU_LOG("\nDEBUG  -->  LWR_MAC: MSG4 sent...");
-                  }
-                  else
-                  { 
-                     /* Filling other DL msg params */
-                     rntiType = C_RNTI_TYPE;
-                     fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
-                           &currDlSlot->dlInfo, rntiType, CORESET_TYPE1);
-                     DU_LOG("\nDEBUG  -->  LWR_MAC: DL MSG sent...");
+                     if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.isMsg4Pdu)
+                     {
+                        rntiType = TC_RNTI_TYPE;
+                        fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
+                              &currDlSlot->dlInfo, rntiType, CORESET_TYPE0);
+                     }
+                     else
+                     { 
+                        /* Filling other DL msg params */
+                        rntiType = C_RNTI_TYPE;
+                        fillPdcchPdu(&dlTtiReq->pdus[numPduEncoded], \
+                              &currDlSlot->dlInfo, rntiType, CORESET_TYPE1);
+                     }
+                     numPduEncoded++;
                   }
-                  DU_LOG("\033[0m");
 
-                  numPduEncoded++;
-                  fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],
-                        &currDlSlot->dlInfo.dlMsgAlloc->dlMsgPdschCfg,
-                        currDlSlot->dlInfo.dlMsgAlloc->bwp,
-                        pduIndex);
-                  numPduEncoded++;
-                  pduIndex++;
+                  if((currDlSlot->dlInfo.dlMsgAlloc->pduPres == BOTH) || \
+                        (currDlSlot->dlInfo.dlMsgAlloc->pduPres == PDSCH_PDU))
+                  {
+                     fillPdschPdu(&dlTtiReq->pdus[numPduEncoded],&currDlSlot->dlInfo.dlMsgAlloc->dlMsgPdschCfg,
+                     currDlSlot->dlInfo.dlMsgAlloc->bwp,pduIndex);
+                     numPduEncoded++;
+                     pduIndex++;
+                     DU_LOG("\033[1;32m");
+                     if(currDlSlot->dlInfo.dlMsgAlloc->dlMsgInfo.isMsg4Pdu)
+                     {
+                        DU_LOG("\nDEBUG  -->  LWR_MAC: MSG4 sent...");
+                     }
+                     else
+                     {
+                        DU_LOG("\nDEBUG  -->  LWR_MAC: DL MSG sent...");
+                     }
+                     DU_LOG("\033[0m");
+                  }
+                 
                }
                else
                {
@@ -3659,10 +3677,9 @@ uint16_t sendTxDataReq(SlotTimingInfo currTimingInfo, DlSchedInfo *dlInfo, p_fap
       if(dlInfo->dlMsgAlloc != NULLP)
       {
          fillDlMsgTxDataReq(txDataReq->pdu_desc, pduIndex, &dlInfo->dlMsgAlloc->dlMsgInfo,\
-           dlInfo->dlMsgAlloc->dlMsgPdschCfg);
+         dlInfo->dlMsgAlloc->dlMsgPdschCfg);
          pduIndex++;
          txDataReq->num_pdus++;
-
          MAC_FREE(dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPdu,\
             dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPduLen);
          dlInfo->dlMsgAlloc->dlMsgInfo.dlMsgPdu = NULLP;
index a98832a..8fd6a87 100644 (file)
@@ -931,6 +931,7 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
 #ifdef NR_TDD
    uint16_t slotIdx = 0;
 #endif
+   DlMsgInfo dlMsgInfo;
    SchUeCb *ueCb = NULLP;
    SchCellCb *cell = NULLP;
    SchDlSlotInfo *schDlSlotInfo = NULLP;
@@ -953,67 +954,76 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
    ueCb = &cell->ueCb[ueIdx-1];
    lcId  = dlBoInfo->lcId;
 
-   if(lcId == SRB1_LCID || lcId == SRB2_LCID || lcId == SRB3_LCID || \
-         (lcId >= MIN_DRB_LCID && lcId <= MAX_DRB_LCID))
+   memset(&dlMsgInfo, 0, sizeof(DlMsgInfo));
+   dlMsgInfo.crnti = dlBoInfo->crnti;
+   dlMsgInfo.ndi = 1;
+   dlMsgInfo.harqProcNum = 0;
+   dlMsgInfo.dlAssignIdx = 0;
+   dlMsgInfo.pucchTpc = 0;
+   dlMsgInfo.pucchResInd = 0;
+   dlMsgInfo.harqFeedbackInd = 0;
+   dlMsgInfo.dciFormatId = 1;
+   
+   if(lcId == SRB0_LCID)
+   {
+      cell->raCb[ueIdx -1].msg4recvd = true;
+      dlMsgInfo.dlMsgPduLen = dlBoInfo->dataVolume;
+      cell->raCb[ueIdx -1].dlMsgInfo = dlMsgInfo;
+   }
+   else
    {
-      SET_ONE_BIT(ueIdx, cell->boIndBitMap);
-      if(ueCb->dlInfo.dlLcCtxt[lcId].lcId == lcId)
+      /* TODO : These part of changes will be corrected during DL scheduling as
+       * per K0 - K1 -K2 */
+      if(lcId == SRB1_LCID || lcId == SRB2_LCID || lcId == SRB3_LCID || \
+            (lcId >= MIN_DRB_LCID && lcId <= MAX_DRB_LCID))
       {
-         ueCb->dlInfo.dlLcCtxt[lcId].bo = dlBoInfo->dataVolume;
+         SET_ONE_BIT(ueIdx, cell->boIndBitMap);
+         if(ueCb->dlInfo.dlLcCtxt[lcId].lcId == lcId)
+         {
+            ueCb->dlInfo.dlLcCtxt[lcId].bo = dlBoInfo->dataVolume;
+         }
+         else
+         {
+            DU_LOG("ERROR --> SCH: LCID:%d is not configured in SCH Cb",lcId);
+            return RFAILED;
+         }
       }
-      else
+      else if(lcId != SRB0_LCID)
       {
-         DU_LOG("ERROR --> SCH: LCID:%d is not configured in SCH Cb",lcId);
+         DU_LOG("\nERROR  -->  SCH : Invalid LC Id %d in MacSchDlRlcBoInfo", lcId);
          return RFAILED;
       }
-   }
-   else if(lcId != SRB0_LCID)
-   {
-      DU_LOG("\nERROR  -->  SCH : Invalid LC Id %d in MacSchDlRlcBoInfo", lcId);
-      return RFAILED;
-   }
 
-   slot = (cell->slotInfo.slot + SCHED_DELTA + PHY_DELTA_DL + BO_DELTA) % cell->numSlots;
+      slot = (cell->slotInfo.slot + SCHED_DELTA + PHY_DELTA_DL + BO_DELTA) % cell->numSlots;
 #ifdef NR_TDD
-   while(schGetSlotSymbFrmt(cell->slotFrmtBitMap, slot) != DL_SLOT)
-   {
-      slot = (slot + 1)%cell->numSlots;
-      slotIdx++;
-      if(slotIdx==cell->numSlots)
+      while(schGetSlotSymbFrmt(cell->slotFrmtBitMap, slot) != DL_SLOT)
       {
-         DU_LOG("\nERROR  -->  SCH : No DL Slot available");
-         return RFAILED;
+         slot = (slot + 1)%cell->numSlots;
+         slotIdx++;
+         if(slotIdx==cell->numSlots)
+         {
+            DU_LOG("\nERROR  -->  SCH : No DL Slot available");
+            return RFAILED;
+         }
       }
-   }
 #endif
 
-   schDlSlotInfo = cell->schDlSlotInfo[slot];
+      schDlSlotInfo = cell->schDlSlotInfo[slot];
+      if(schDlSlotInfo == NULLP)
+      {
+         DU_LOG("\nERROR  -->  SCH : MacSchDlRlcBoInfo(): schDlSlotInfo does not exists");
+         return RFAILED;
+      }
 
-   if(schDlSlotInfo == NULLP)
-   {
-      DU_LOG("\nERROR  -->  SCH : MacSchDlRlcBoInfo(): schDlSlotInfo does not exists");
-      return RFAILED;
-   }
-   SCH_ALLOC(schDlSlotInfo->dlMsgInfo, sizeof(DlMsgInfo));
-   if(schDlSlotInfo->dlMsgInfo == NULLP)
-   {
-      DU_LOG("\nERROR  -->  SCH : Memory allocation failed for dlMsgInfo");
-      schDlSlotInfo = NULL;
-      return RFAILED;
-   }
+      SCH_ALLOC(schDlSlotInfo->dlMsgAlloc, sizeof(DlMsgAlloc));
+      if(schDlSlotInfo->dlMsgAlloc == NULLP)
+      {
+         DU_LOG("\nERROR  -->  SCH : Memory allocation failed for dlMsgInfo");
+         schDlSlotInfo = NULL;
+         return RFAILED;
+      }
 
-   schDlSlotInfo->dlMsgInfo->crnti = dlBoInfo->crnti;
-   schDlSlotInfo->dlMsgInfo->ndi = 1;
-   schDlSlotInfo->dlMsgInfo->harqProcNum = 0;
-   schDlSlotInfo->dlMsgInfo->dlAssignIdx = 0;
-   schDlSlotInfo->dlMsgInfo->pucchTpc = 0;
-   schDlSlotInfo->dlMsgInfo->pucchResInd = 0;
-   schDlSlotInfo->dlMsgInfo->harqFeedbackInd = 0;
-   schDlSlotInfo->dlMsgInfo->dciFormatId = 1;
-   if(lcId == SRB0_LCID)
-   {
-      schDlSlotInfo->dlMsgInfo->isMsg4Pdu = true;
-      schDlSlotInfo->dlMsgInfo->dlMsgPduLen = dlBoInfo->dataVolume;
+      schDlSlotInfo->dlMsgAlloc->dlMsgInfo = dlMsgInfo;
    }
    return ROK;
 }
index 3c78a50..8212299 100644 (file)
@@ -141,12 +141,14 @@ typedef struct schDlSlotInfo
    SsbInfo      ssbInfo[MAX_SSB_IDX];     /*!< SSB info */
    bool         sib1Pres;                 /*!< Flag to determine if SIB1 is present in this slot */
    RarAlloc     *rarAlloc;                /*!< RAR allocation */
-   DlMsgInfo    *dlMsgInfo;               /*!< DL dedicated Msg info */
+   DlMsgAlloc   *dlMsgAlloc;               /*!< Dl msg allocation */
 }SchDlSlotInfo;
 
 typedef struct schRaCb
 {
-   uint16_t tcrnti;
+   bool      msg4recvd;
+   DlMsgInfo dlMsgInfo;
+   uint16_t  tcrnti;
 }SchRaCb;
 
 /**
@@ -353,10 +355,11 @@ PduTxOccsaion schCheckSib1Occ(SchCellCb *cell, SlotTimingInfo slotTime);
 uint8_t schBroadcastSsbAlloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcstAlloc *dlBrdcstAlloc);
 uint8_t schBroadcastSib1Alloc(SchCellCb *cell, SlotTimingInfo slotTime, DlBrdcstAlloc *dlBrdcstAlloc);
 void schProcessRaReq(SlotTimingInfo currTime, SchCellCb *cellCb);
+uint8_t schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime);
 uint8_t schFillRar(SchCellCb *cell, SlotTimingInfo rarTime, uint16_t ueIdx, RarAlloc *rarAlloc, uint8_t k0Index);
-uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo slotTime, DlMsgAlloc *msg4Alloc);
 uint8_t schDlRsrcAllocDlMsg(SchCellCb *cell, SlotTimingInfo slotTime, uint16_t crnti,\
    uint32_t tbSize, DlMsgAlloc *dlMsgAlloc, uint16_t startPRB);
+uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueIdx, DlMsgAlloc *msg4Alloc, uint8_t k0Idx);
 uint16_t schAccumalateLcBoSize(SchCellCb *cell, uint16_t ueIdx);
 uint8_t allocatePrbDl(SchCellCb *cell, SlotTimingInfo slotTime, uint8_t startSymbol, uint8_t symbolLength, \
    uint16_t *startPrb, uint16_t numPrb);
@@ -368,7 +371,7 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst);
 bool schCheckPrachOcc(SchCellCb *cell, SlotTimingInfo prachOccasionTimingInfo);
 uint8_t schCalcPrachNumRb(SchCellCb *cell);
 void schPrachResAlloc(SchCellCb *cell, UlSchedInfo *ulSchedInfo, SlotTimingInfo prachOccasionTimingInfo);
-uint16_t schAllocPucchResource(SchCellCb *cell, uint16_t crnti, uint16_t slot);
+uint16_t schAllocPucchResource(SchCellCb *cell, SlotTimingInfo pucchTime, uint16_t crnti);
 uint8_t schFillUlDci(SchUeCb *ueCb, SchPuschInfo puschInfo, DciInfo *dciInfo);
 uint8_t schFillPuschAlloc(SchUeCb *ueCb, SlotTimingInfo pdcchSlotTime, uint32_t dataVol, SchPuschInfo *puschInfo);
 uint8_t allocatePrbUl(SchCellCb *cell, SlotTimingInfo slotTime, uint8_t startSymbol, uint8_t symbolLength, \
index 75a65f7..dbf5940 100644 (file)
@@ -511,7 +511,7 @@ uint8_t schUlResAlloc(SchCellCb *cell, Inst schInst)
  *         RFAILED - failure
  *
  * ****************************************************************/
-uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo slotTime, DlMsgAlloc *msg4Alloc)
+uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo msg4Time, uint8_t ueIdx, DlMsgAlloc *msg4Alloc, uint8_t k0Idx)
 {
    uint8_t coreset0Idx = 0;
    uint8_t firstSymbol = 0;
@@ -537,12 +537,14 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo slotTime, DlMsgAlloc
       return RFAILED;
    }
 
+   initialBwp   = &cell->cellCfg.schInitialDlBwp;
    pdcch = &msg4Alloc->dlMsgPdcchCfg;
    pdsch = &msg4Alloc->dlMsgPdschCfg;
    bwp = &msg4Alloc->bwp;
-   initialBwp   = &cell->cellCfg.schInitialDlBwp;
    coreset0Idx  = initialBwp->pdcchCommon.commonSearchSpace.coresetId;
 
+   msg4Alloc->dlMsgInfo = cell->raCb[ueIdx].dlMsgInfo;
+   msg4Alloc->dlMsgInfo.isMsg4Pdu = true;
    /* derive the sib1 coreset0 params from table 13-1 spec 38.213 */
    numRbs     = coresetIdxTable[coreset0Idx][1];
    numSymbols = coresetIdxTable[coreset0Idx][2];
@@ -577,7 +579,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo slotTime, DlMsgAlloc
    pdcch->coresetCfg.shiftIndex = cell->cellCfg.phyCellId;
    pdcch->coresetCfg.precoderGranularity = 0; /* sameAsRegBundle */
    pdcch->numDlDci = 1;
-   pdcch->dci.rnti = cell->schDlSlotInfo[slotTime.slot]->dlMsgInfo->crnti;
+   pdcch->dci.rnti = cell->raCb[ueIdx].tcrnti;
    pdcch->dci.scramblingId = cell->cellCfg.phyCellId;
    pdcch->dci.scramblingRnti = 0;
    pdcch->dci.cceIndex = 4; /* considering SIB1 is sent at cce 0-1-2-3 */
@@ -589,11 +591,12 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo slotTime, DlMsgAlloc
    pdcch->dci.beamPdcchInfo.prg[0].beamIdx[0] = 0;
    pdcch->dci.txPdcchPower.powerValue = 0;
    pdcch->dci.txPdcchPower.powerControlOffsetSS = 0;
+   pdcch->dci.pdschCfg = pdsch;
 
    /* fill the PDSCH PDU */
    uint8_t cwCount = 0;
    pdsch->pduBitmap = 0; /* PTRS and CBG params are excluded */
-   pdsch->rnti = cell->schDlSlotInfo[slotTime.slot]->dlMsgInfo->crnti;
+   pdsch->rnti = cell->raCb[ueIdx].tcrnti;
    pdsch->pduIndex = 0;
    pdsch->numCodewords = 1;
    for(cwCount = 0; cwCount < pdsch->numCodewords; cwCount++)
@@ -620,12 +623,13 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo slotTime, DlMsgAlloc
    pdsch->dmrs.nrOfDmrsSymbols  = NUM_DMRS_SYMBOLS;
    pdsch->dmrs.dmrsAddPos       = DMRS_ADDITIONAL_POS;
 
-   pdsch->pdschTimeAlloc.timeAlloc.startSymb = 3; /* spec-38.214, Table 5.1.2.1-1 */
-   pdsch->pdschTimeAlloc.timeAlloc.numSymb = NUM_PDSCH_SYMBOL;
+   pdsch->pdschTimeAlloc.timeAlloc.startSymb =initialBwp->pdschCommon.timeDomRsrcAllocList[k0Idx].startSymbol; 
+   pdsch->pdschTimeAlloc.timeAlloc.numSymb = initialBwp->pdschCommon.timeDomRsrcAllocList[k0Idx].lengthSymbol;
 
    pdsch->pdschFreqAlloc.resourceAllocType = 1; /* RAT type-1 RIV format */
    pdsch->pdschFreqAlloc.freqAlloc.startPrb = MAX_NUM_RB;
-   pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, NUM_PDSCH_SYMBOL);
+   pdsch->pdschFreqAlloc.freqAlloc.numPrb = schCalcNumPrb(tbSize, mcs, \
+   initialBwp->pdschCommon.timeDomRsrcAllocList[k0Idx].lengthSymbol);
    pdsch->pdschFreqAlloc.vrbPrbMapping = 0; /* non-interleaved */
 
    /* Find total symbols occupied including DMRS */
@@ -645,7 +649,7 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo slotTime, DlMsgAlloc
    }
 
    /* Allocate the number of PRBs required for RAR PDSCH */
-   if((allocatePrbDl(cell, slotTime, startSymbol, numSymbol,\
+   if((allocatePrbDl(cell, msg4Time, startSymbol, numSymbol,\
       &pdsch->pdschFreqAlloc.freqAlloc.startPrb, pdsch->pdschFreqAlloc.freqAlloc.numPrb)) != ROK)
    {
       DU_LOG("\nERROR  --> SCH : Resource allocation failed for MSG4");
@@ -660,34 +664,32 @@ uint8_t schDlRsrcAllocMsg4(SchCellCb *cell, SlotTimingInfo slotTime, DlMsgAlloc
    pdsch->txPdschPower.powerControlOffset = 0;
    pdsch->txPdschPower.powerControlOffsetSS = 0;
 
-   pdcch->dci.pdschCfg = pdsch;
-
    return ROK;
 }
  
-uint16_t schAllocPucchResource(SchCellCb *cell, uint16_t crnti, uint16_t slot)
+/*******************************************************************
+ *
+ * @brief Scheduling for Pucch Resource
+ *
+ * @details
+ *
+ *    Function : schAllocPucchResource
+ *
+ *    Functionality:
+ *       Scheduling for Pucch Resource
+ *
+ * @params[in] SchCellCb *cell, SlotTimingInfo pucchTime, crnti
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ *******************************************************************/
+
+uint16_t schAllocPucchResource(SchCellCb *cell, SlotTimingInfo pucchTime, uint16_t crnti)
 {
-   uint8_t k1 = SCH_DEFAULT_K1, ueIdx = 0, dlToUlAckIdx;
    uint16_t pucchSlot = 0;
    SchUlSlotInfo  *schUlSlotInfo = NULLP;
-   SchPucchCfg    *schPucchCfg = NULLP;
-
-   GET_UE_IDX(crnti, ueIdx);
-   if(cell->ueCb[ueIdx].ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres)
-   {
-      schPucchCfg = &(cell->ueCb[ueIdx].ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg);
-      if(schPucchCfg->dlDataToUlAck)
-      {
-         for(dlToUlAckIdx = 0; dlToUlAckIdx < schPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; dlToUlAckIdx++)
-         {
-            //For now considering only the first value in the list
-            k1 = schPucchCfg->dlDataToUlAck->dlDataToUlAckList[dlToUlAckIdx];
-            break;
-         }
-      }
-   }
    
-   pucchSlot = (slot + k1)  % cell->numSlots;
+   pucchSlot = pucchTime.slot;
    schUlSlotInfo = cell->schUlSlotInfo[pucchSlot];
    memset(&schUlSlotInfo->schPucchInfo, 0, sizeof(SchPucchInfo));
 
@@ -1560,6 +1562,149 @@ void updateGrantSizeForBoRpt(CmLListCp *lcLL, DlMsgAlloc *dlMsgAlloc, uint32_t *
    return;
 }
 
+/*******************************************************************
+ *
+ * @brief sch Process pending Msg4 Req
+ *
+ * @details
+ *
+ *    Function : schProcessMsg4Req
+ *
+ *    Functionality:
+ *       sch Process pending Msg4 Req
+ *
+ * @params[in] SchCellCb *cell,  SlotTimingInfo currTime 
+ * @return ROK     - success
+ *         RFAILED - failure
+ *
+ *******************************************************************/
+
+uint8_t schProcessMsg4Req(SchCellCb *cell, SlotTimingInfo currTime)
+{
+   bool k1Found = FALSE;  
+   uint16_t pdcchSlot = 0, pdschSlot = 0;
+   uint8_t ueIdx = 0, numK0 = 0, k0TblIdx = 0, k0Index = 0, k0Val = 0;
+   uint8_t k1TblIdx = 0, k1Index = 0, k1Val = 0, numK1 = 0;
+   SchK0K1TimingInfoTbl *k0K1InfoTbl;
+   SlotTimingInfo pdcchTime, pdschTime, pucchTime;
+   DlMsgAlloc *dciSlotAlloc = NULLP;    /* Stores info for transmission of PDCCH for Msg4 */
+   DlMsgAlloc  *msg4SlotAlloc = NULLP;   /* Stores info for transmission of PDSCH for Msg4 */
+
+   if(cell == NULL)
+   {
+      DU_LOG("\nERROR  -->  SCH: schDlRsrcAllocMsg4() : Cell is NULL");
+      return RFAILED;
+   }
+
+   while(ueIdx < MAX_NUM_UE)
+   {
+      if(cell->raCb[ueIdx].msg4recvd == FALSE)
+      {
+         ueIdx++;
+         continue;
+      }
+
+      ADD_DELTA_TO_TIME(currTime, pdcchTime, PHY_DELTA_DL + SCHED_DELTA);
+      pdcchSlot = pdcchTime.slot;
+#ifdef NR_TDD
+      if(schGetSlotSymbFrmt(pdcchSlot, cell->slotFrmtBitMap) != DL_SLOT)
+      {
+         continue;
+      }
+#endif
+      k0K1InfoTbl = &cell->cellCfg.schInitialDlBwp.k0K1InfoTbl;
+      numK0 = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].numK0;
+      for(k0TblIdx = 0; k0TblIdx < numK0; k0TblIdx++)
+      {
+         k0Index = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].k0Indexes[k0TblIdx].k0Index;
+         k0Val = cell->cellCfg.schInitialDlBwp.pdschCommon.timeDomRsrcAllocList[k0Index].k0;
+
+         ADD_DELTA_TO_TIME(pdcchTime, pdschTime, k0Val);
+         pdschSlot = pdschTime.slot;
+#ifdef NR_TDD
+         if(schGetSlotSymbFrmt(pdschSlot, cell->slotFrmtBitMap) != DL_SLOT)
+         {
+            continue;
+         }
+#endif
+         numK1 = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].k0Indexes[k0TblIdx].k1TimingInfo.numK1;
+         for(k1TblIdx = 0; k1TblIdx < numK1; k1TblIdx++)
+         {
+            k1Index = k0K1InfoTbl->k0k1TimingInfo[pdcchSlot].k0Indexes[k0TblIdx].k1TimingInfo.k1Indexes[k1TblIdx];
+            k1Val = defaultUlAckTbl[k1Index];
+
+            ADD_DELTA_TO_TIME(pdschTime, pucchTime, k1Val);
+#ifdef NR_TDD
+            if(schGetSlotSymbFrmt(pucchTime.slot, cell->slotFrmtBitMap) == DL_SLOT)
+            {
+               continue;
+            }
+#endif
+            k1Found = true;
+            break;
+         }
+         if(k1Found)
+            break;
+      }
+
+      /* If K0-K1 combination not found, no scheduling happens */
+      if(!k1Found)
+      {
+         ueIdx++;
+         continue;
+      }
+      
+      SCH_ALLOC(dciSlotAlloc, sizeof(DlMsgAlloc));
+      if(dciSlotAlloc == NULLP)
+      {
+         DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for dciSlotAlloc");
+         return RFAILED;
+      }
+      cell->schDlSlotInfo[pdcchSlot]->dlMsgAlloc = dciSlotAlloc;
+
+      /* Fill PDCCH and PDSCH scheduling information for Msg4 */
+      if((schDlRsrcAllocMsg4(cell, pdschTime, ueIdx, dciSlotAlloc, k0Index)) != ROK)
+      {
+         DU_LOG("\nERROR  -->  SCH: Scheduling of Msg4 failed in slot [%d]", pdschSlot);
+         SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
+         cell->schDlSlotInfo[pdcchSlot]->dlMsgAlloc = NULLP;
+         return RFAILED;
+      }
+      /* Check if both DCI and RAR are sent in the same slot.
+      * If not, allocate memory RAR PDSCH slot to store RAR info
+      */
+      if(pdcchSlot == pdschSlot)
+         dciSlotAlloc->pduPres = BOTH;
+      else
+      {
+         /* Allocate memory to schedule rarSlot to send RAR, pointer will be checked at schProcessSlotInd() */
+         SCH_ALLOC(msg4SlotAlloc, sizeof(DlMsgAlloc));
+         if(msg4SlotAlloc == NULLP)
+         {
+            DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for msg4SlotAlloc");
+            SCH_FREE(dciSlotAlloc, sizeof(DlMsgAlloc));
+            cell->schDlSlotInfo[pdcchSlot]->rarAlloc = NULLP;
+            return RFAILED;
+         }
+         cell->schDlSlotInfo[pdschSlot]->dlMsgAlloc = msg4SlotAlloc;
+
+         /* Copy all RAR info */
+         memcpy(msg4SlotAlloc, dciSlotAlloc, sizeof(DlMsgAlloc));
+         msg4SlotAlloc->dlMsgPdcchCfg.dci.pdschCfg = &msg4SlotAlloc->dlMsgPdschCfg;
+
+         /* Assign correct PDU types in corresponding slots */
+         msg4SlotAlloc->pduPres = PDSCH_PDU;
+         dciSlotAlloc->pduPres = PDCCH_PDU;
+         dciSlotAlloc->pdschSlot = pdschSlot;
+      }
+
+      /* PUCCH resource */
+      schAllocPucchResource(cell, pucchTime, cell->raCb[ueIdx].tcrnti);
+      cell->raCb[ueIdx].msg4recvd = FALSE;
+      ueIdx++;
+   }
+   return ROK;
+}
 /**********************************************************************
   End of file
  **********************************************************************/
index e1b9619..050752c 100644 (file)
@@ -221,6 +221,7 @@ void createSchRaCb(uint16_t tcrnti, Inst schInst)
 
    GET_UE_IDX(tcrnti, ueIdx);
    schCb[schInst].cells[schInst]->raCb[ueIdx -1].tcrnti = tcrnti;
+   schCb[schInst].cells[schInst]->raCb[ueIdx -1].msg4recvd = FALSE;
 }
 
 /**
index 52a3067..913111c 100644 (file)
@@ -205,13 +205,15 @@ PduTxOccsaion schCheckSib1Occ(SchCellCb *cell, SlotTimingInfo slotTime)
  * ****************************************************************/
 uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlMsgAlloc *dlMsgAlloc)
 {
-   uint8_t ueIdx = 0, lcIdx = 0, pdschSymbols = 0;
-   uint16_t slot = 0,  startPrb = 0, maxFreePRB = 0;
+   uint8_t ueIdx = 0, lcIdx = 0, pdschSymbols = 0, k1 = 0;
+   uint16_t slot = 0,  startPrb = 0, maxFreePRB = 0,dlToUlAckIdx =0;
    uint16_t crnti = 0, mcsIdx = 0;
    uint32_t accumalatedSize = 0;
    SchUeCb *ueCb = NULLP;
    CmLListCp *lcLL = NULLP;
    SchPdschConfig pdschCfg;
+   SlotTimingInfo pucchTime;
+   SchPucchCfg *schPucchCfg;
 
    /* TX_PAYLOAD_HDR_LEN: Overhead which is to be Added once for any UE while estimating Accumulated TB Size
     * Following flag added to keep the record whether TX_PAYLOAD_HDR_LEN is added to the first Node getting allocated.
@@ -245,8 +247,8 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
        * pdschCfg.timeDomRsrcAllociList*/
       pdschSymbols = pdschCfg.timeDomRsrcAllociList[0].symbolLength;
       /* Dl ded Msg info is copied, this was earlier filled in macSchDlRlcBoInfo */
-      memcpy(&dlMsgAlloc->dlMsgInfo, cell->schDlSlotInfo[slot]->dlMsgInfo, \
-            sizeof(DlMsgInfo));
+      memcpy(&dlMsgAlloc->dlMsgInfo, &cell->schDlSlotInfo[slot]->dlMsgAlloc->dlMsgInfo, \
+           sizeof(DlMsgInfo));
 
       /*Re-Initalization per UE*/
       /* scheduled LC data fill */
@@ -352,6 +354,7 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
           * Allocation can be done in next slot*/
          return ROK;
       }
+      
       /*[Step6]: pdcch and pdsch data is filled */
       if((schDlRsrcAllocDlMsg(cell, dlSchedInfo->schSlotValue.dlMsgTime, \
                   crnti, accumalatedSize, dlMsgAlloc, startPrb)) != ROK)
@@ -362,6 +365,8 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
          dlSchedInfo->dlMsgAlloc = NULLP;
          return RFAILED;
       }
+      
+      dlMsgAlloc->pduPres = BOTH;
 
       /* TODO : Update the scheduling byte report for multiple LC based on QCI
        * and Priority */
@@ -375,7 +380,22 @@ uint8_t schFillBoGrantDlSchedInfo(SchCellCb *cell, DlSchedInfo *dlSchedInfo, DlM
          dlMsgAlloc->lcSchInfo[lcIdx].schBytes = accumalatedSize;
 #endif
       /* PUCCH resource */
-      schAllocPucchResource(cell, dlMsgAlloc->crnti, slot);
+      /* TODO : Correct values of K1 will be used from K0K1 table */ 
+      if(cell->ueCb[ueIdx].ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfgPres)
+      {
+         schPucchCfg = &(cell->ueCb[ueIdx].ueCfg.spCellCfg.servCellCfg.initUlBwp.pucchCfg);
+         if(schPucchCfg->dlDataToUlAck)
+         {
+            for(dlToUlAckIdx = 0; dlToUlAckIdx < schPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; dlToUlAckIdx++)
+            {
+               //For now considering only the first value in the list
+               k1 = schPucchCfg->dlDataToUlAck->dlDataToUlAckList[dlToUlAckIdx];
+               break;
+            }
+         }
+      }
+      ADD_DELTA_TO_TIME(dlSchedInfo->schSlotValue.dlMsgTime, pucchTime, k1);
+      schAllocPucchResource(cell, pucchTime, crnti);
 
       /* after allocation is done, unset the bo bit for that ue */
       UNSET_ONE_BIT(ueIdx, cell->boIndBitMap);
@@ -406,7 +426,6 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
    uint16_t slot;
    DlSchedInfo dlSchedInfo;
    DlBrdcstAlloc *dlBrdcstAlloc = NULLP;
-   DlMsgAlloc  *msg4Alloc = NULLP;
    DlMsgAlloc *dlMsgAlloc = NULLP;
    SchCellCb  *cell = NULLP;
 
@@ -427,7 +446,6 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
    dlBrdcstAlloc->ssbIdxSupported = SSB_IDX_SUPPORTED;
 
    dlSchedInfo.cellId = cell->cellId;
-
    slot = dlSchedInfo.schSlotValue.broadcastTime.slot;
 
    /* Check for SSB occassion */
@@ -474,40 +492,16 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
       dlSchedInfo.rarAlloc = cell->schDlSlotInfo[slot]->rarAlloc;
       cell->schDlSlotInfo[slot]->rarAlloc = NULLP;
    }
+   
+   schProcessMsg4Req(cell, *slotInd);
 
    /* Check for MSG4 */
-   if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo != NULLP) &&
-      (cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo->isMsg4Pdu))
+   if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc != NULLP) &&
+      (cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc->dlMsgInfo.isMsg4Pdu))
    {
       slot = dlSchedInfo.schSlotValue.dlMsgTime.slot;
-
-      SCH_ALLOC(msg4Alloc, sizeof(DlMsgAlloc));
-      if(!msg4Alloc)
-      {
-         DU_LOG("\nERROR  -->  SCH : Memory Allocation failed for msg4 alloc");
-         return RFAILED;
-      }
-
-      dlSchedInfo.dlMsgAlloc = msg4Alloc;
-
-      /* Msg4 info is copied, this was earlier filled in macSchDlRlcBoInfo */
-      memcpy(&msg4Alloc->dlMsgInfo, cell->schDlSlotInfo[slot]->dlMsgInfo, \
-           sizeof(DlMsgInfo));
-
-      /* pdcch and pdsch data is filled */
-      if((schDlRsrcAllocMsg4(cell, dlSchedInfo.schSlotValue.dlMsgTime, msg4Alloc)) != ROK)
-      {
-         DU_LOG("\nERROR  -->  SCH : MSG4 scheduling failed");
-         SCH_FREE(msg4Alloc, sizeof(DlMsgAlloc));
-         dlSchedInfo.dlMsgAlloc = NULLP;
-         SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo, sizeof(DlMsgInfo));
-         return RFAILED;
-      }
-
-      /* PUCCH resource */
-      schAllocPucchResource(cell, msg4Alloc->dlMsgInfo.crnti, dlSchedInfo.schSlotValue.dlMsgTime.slot);
-
-      SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo, sizeof(DlMsgInfo));
+      dlSchedInfo.dlMsgAlloc = cell->schDlSlotInfo[slot]->dlMsgAlloc;
+      cell->schDlSlotInfo[slot]->dlMsgAlloc = NULLP;
    }
 
    /* Check if UL grant must be sent in this slot for a SR/BSR that had been received */
@@ -557,18 +551,18 @@ uint8_t schProcessSlotInd(SlotTimingInfo *slotInd, Inst schInst)
    }
 
    /* Check for pending BO grant for LC */
-   if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo != NULLP) &&
-      (!cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo->isMsg4Pdu))
+   if((cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc != NULLP) &&
+      (!cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc->dlMsgInfo.isMsg4Pdu))
    {
       if((schFillBoGrantDlSchedInfo(cell, &dlSchedInfo, dlMsgAlloc)) != ROK)
       {
          DU_LOG("\nERROR  -->  SCH : DL MSG scheduling failed");
-         SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo, sizeof(DlMsgInfo));
+         SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc, sizeof(DlMsgAlloc));
          return RFAILED;
       }
 
       /* Free the dl ded msg info allocated in macSchDlRlcBoInfo */
-      SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgInfo, sizeof(DlMsgInfo));
+      SCH_FREE(cell->schDlSlotInfo[dlSchedInfo.schSlotValue.dlMsgTime.slot]->dlMsgAlloc, sizeof(DlMsgAlloc));
    }
 
    /* Send msg to MAC */
index 8be797c..ce02fd4 100644 (file)
@@ -1099,18 +1099,40 @@ uint8_t SchSendCellDeleteRspToMac(SchCellDelete  *ueDelete, Inst inst, SchMacRsp
 void deleteSchCellCb(SchCellCb *cellCb)
 {
    uint8_t sliceIdx=0, slotIdx=0;
+   CmLListCp *list;
+   CmLList *node, *next;
+
    if(cellCb->schDlSlotInfo)
    {
       for(slotIdx=0; slotIdx<cellCb->numSlots; slotIdx++)
       {
+         list = &cellCb->schDlSlotInfo[slotIdx]->prbAlloc.freePrbBlockList;
+         node = list->first;
+         while(node)
+         {
+            next = node->next;
+            SCH_FREE(node->node, sizeof(FreePrbBlock));
+            deleteNodeFromLList(list, node);
+            node = next;
+         }
          SCH_FREE(cellCb->schDlSlotInfo[slotIdx], sizeof(SchDlSlotInfo));
       }
       SCH_FREE(cellCb->schDlSlotInfo, cellCb->numSlots *sizeof(SchDlSlotInfo*));
    }
+
    if(cellCb->schUlSlotInfo)
    {
       for(slotIdx=0; slotIdx<cellCb->numSlots; slotIdx++)
       {
+         list = &cellCb->schUlSlotInfo[slotIdx]->prbAlloc.freePrbBlockList;
+         node = list->first;
+         while(node)
+         {
+            next = node->next;
+            SCH_FREE(node->node, sizeof(FreePrbBlock));
+            deleteNodeFromLList(list, node);
+            node = next;
+         }
          SCH_FREE(cellCb->schUlSlotInfo[slotIdx], sizeof(SchUlSlotInfo));  
       }
       SCH_FREE(cellCb->schUlSlotInfo,  cellCb->numSlots * sizeof(SchUlSlotInfo*));
index 6e43eaf..1905d65 100644 (file)
@@ -410,6 +410,7 @@ typedef enum
 
 typedef enum
 {
+   NONE,
    PDCCH_PDU,
    PDSCH_PDU,
    BOTH
@@ -868,6 +869,8 @@ typedef struct dlMsgAlloc
    BwpCfg     bwp;
    PdcchCfg   dlMsgPdcchCfg;
    PdschCfg   dlMsgPdschCfg;
+   DlPduType  pduPres;
+   uint8_t    pdschSlot;
    DlMsgInfo  dlMsgInfo;
 }DlMsgAlloc;