<[Epic-ID: ODUHIGH-406][Task-ID: ODUHIGH-421]Paging Message: CU_STUB Trigger and...
[o-du/l2.git] / src / 5gnrsch / sch.c
index f0bf4e7..fe18fec 100644 (file)
@@ -142,9 +142,7 @@ uint8_t SchInstCfg(RgCfg *cfg, Inst  dInst)
       return LCM_REASON_INVALID_MSGTYPE;
    }
    /* Update the Pst structure for LM interface */
-   memcpy(&schCb[inst].schInit.lmPst,
-        &cfg->s.schInstCfg.genCfg.lmPst,
-        sizeof(Pst));
+   memcpy(&schCb[inst].schInit.lmPst, &cfg->s.schInstCfg.genCfg.lmPst, sizeof(Pst));
 
    schCb[inst].schInit.inst = inst;
    schCb[inst].schInit.lmPst.srcProcId = schCb[inst].schInit.procId;
@@ -170,8 +168,7 @@ uint8_t SchInstCfg(RgCfg *cfg, Inst  dInst)
 
    /* SS_MT_TMR needs to be enabled as schActvTmr needs instance information */
    /* Timer Registration request to system services */
-   if (ODU_REG_TMR_MT(schCb[inst].schInit.ent, dInst,
-           (int)schCb[inst].genCfg.tmrRes, schActvTmr) != ROK)
+   if (ODU_REG_TMR_MT(schCb[inst].schInit.ent, dInst, (int)schCb[inst].genCfg.tmrRes, schActvTmr) != ROK)
    {
       DU_LOG("\nERROR  -->  SCH : SchInstCfg(): Failed to "
            "register timer.");
@@ -868,7 +865,7 @@ uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg)
    SchCellCb *cellCb;
    SchCellCfgCfm schCellCfgCfm;
    Pst rspPst;
-   Inst inst = pst->dstInst-1
+   Inst inst = pst->dstInst - SCH_INST_START
    uint8_t coreset0Idx = 0;
    uint8_t numRbs = 0;
    uint8_t offset = 0;
@@ -887,7 +884,10 @@ uint8_t SchHdlCellCfgReq(Pst *pst, SchCellCfg *schCellCfg)
    fillSchSib1Cfg(schCellCfg->numerology, schCellCfg->bandwidth, cellCb->numSlots,
         &(schCellCfg->sib1SchCfg), schCellCfg->phyCellId,
         schCellCfg->ssbSchCfg.ssbOffsetPointA);
+   
+   
    memcpy(&cellCb->cellCfg, schCellCfg, sizeof(SchCellCfg));
+   schProcPagingCfg(cellCb);
 
    /* Fill coreset frequencyDomainResource bitmap */
    coreset0Idx = cellCb->cellCfg.schInitialDlBwp.pdcchCommon.commonSearchSpace.coresetId;
@@ -960,8 +960,14 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
       return RFAILED;
    }
 
-   GET_UE_IDX(dlBoInfo->crnti, ueId);
+   GET_UE_ID(dlBoInfo->crnti, ueId);
    ueCb = &cell->ueCb[ueId-1];
+   if(ueCb->ueCfg.dataTransmissionAction == STOP_DATA_TRANSMISSION)
+   {
+      DU_LOG("INFO  --> SCH : DL Data transmission not allowed for UE %d", ueCb->ueCfg.ueId);
+      return ROK;
+   }
+   
    lcId  = dlBoInfo->lcId;
    CHECK_LCID(lcId, isLcIdValid);
    if(isLcIdValid == FALSE)
@@ -997,8 +1003,6 @@ uint8_t MacSchDlRlcBoInfo(Pst *pst, DlRlcBoInfo *dlBoInfo)
    }
    else
    {
-      /* TODO : These part of changes will be corrected during DL scheduling as
-       * per K0 - K1 -K2 */
       SET_ONE_BIT(ueId, cell->boIndBitMap);
       if(ueCb->dlInfo.dlLcCtxt[lcId].lcId == lcId)
       {
@@ -1064,6 +1068,12 @@ uint8_t MacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd)
       return RFAILED;
    }
 
+   if(ueCb->ueCfg.dataTransmissionAction == STOP_DATA_TRANSMISSION)
+   {
+      DU_LOG("\nINFO --> SCH: UL Data transmission not allowed for UE %d", ueCb->ueCfg.ueId);
+      return ROK;
+   }
+   
    ueCb->bsrRcvd = true;
    /* store dataVolume per lcg in uecb */
    for(lcgIdx = 0; lcgIdx < bsrInd->numLcg; lcgIdx++)
@@ -1073,7 +1083,7 @@ uint8_t MacSchBsr(Pst *pst, UlBufferStatusRptInd *bsrInd)
    }
    
    /* Adding UE Id to list of pending UEs to be scheduled */
-   addUeToBeScheduled(cellCb, ueCb->ueIdx);
+   addUeToBeScheduled(cellCb, ueCb->ueId);
    return ROK;
 }
 
@@ -1114,13 +1124,17 @@ uint8_t MacSchSrUciInd(Pst *pst, SrUciIndInfo *uciInd)
       DU_LOG("\nERROR  -->  SCH : Crnti %d is inactive", uciInd->crnti);
       return ROK;  
    }
-
+   if(ueCb->ueCfg.dataTransmissionAction == STOP_DATA_TRANSMISSION)
+   {
+      DU_LOG("\nINFO --> SCH: UL Data transmission not allowed for UE %d", ueCb->ueCfg.ueId);
+      return ROK;
+   }
    if(uciInd->numSrBits)
    {
       ueCb->srRcvd = true;
       
       /* Adding UE Id to list of pending UEs to be scheduled */
-      addUeToBeScheduled(cellCb, ueCb->ueIdx);
+      addUeToBeScheduled(cellCb, ueCb->ueId);
    }
    return ROK;
 }
@@ -1443,7 +1457,7 @@ uint8_t addUeToBeScheduled(SchCellCb *cell, uint8_t ueIdToAdd)
    *ueId = ueIdToAdd;
    if(addNodeToLList(&cell->ueToBeScheduled, ueId, NULLP) != ROK)
    {
-      DU_LOG("\nERROR  --> SCH : Failed to add UeIdx to cell->ueToBeScheduled list");
+      DU_LOG("\nERROR  --> SCH : Failed to add ueId [%d] to cell->ueToBeScheduled list", *ueId);
       return RFAILED;
    }
    return ROK;
@@ -1748,7 +1762,9 @@ uint8_t addSliceCfgInSchDb(SchSliceCfg *storeSliceCfg, SchSliceCfgReq *cfgReq, S
                return RFAILED;
             }
 
-            memcpy(storeSliceCfg->listOfConfirguration[sliceIdx], cfgReq->listOfConfirguration[sliceIdx], sizeof(SchRrmPolicyOfSlice));
+            memcpy(&storeSliceCfg->listOfConfirguration[sliceIdx]->snssai, &cfgReq->listOfConfirguration[sliceIdx]->snssai, sizeof(Snssai));
+            memcpy(storeSliceCfg->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo, cfgReq->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo,
+                      sizeof(SchRrmPolicyRatio));
             sliceIdx++;
          }
       }
@@ -1815,7 +1831,7 @@ void freeSchSliceCfgReq(SchSliceCfgReq *cfgReq)
 uint8_t MacSchSliceCfgReq(Pst *pst, SchSliceCfgReq *schSliceCfgReq)
 {
    uint8_t count = 0;
-   Inst   inst = pst->dstInst - 1;
+   Inst   inst = pst->dstInst - SCH_INST_START;
    SchSliceCfgRsp sliceCfgRsp;
 
    DU_LOG("\nINFO  -->  SCH : Received Slice Cfg request from MAC");
@@ -1884,7 +1900,8 @@ uint8_t modifySliceCfgInSchDb(SchSliceCfg *storeSliceCfg, SchSliceCfgReq *cfgReq
             {
                if(!memcmp(&storeSliceCfg->listOfConfirguration[sliceIdx]->snssai, &cfgReq->listOfConfirguration[cfgIdx]->snssai, sizeof(Snssai)))
                {
-                  storeSliceCfg->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo = cfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo;
+                  memcpy(storeSliceCfg->listOfConfirguration[sliceIdx]->rrmPolicyRatioInfo, cfgReq->listOfConfirguration[cfgIdx]->rrmPolicyRatioInfo,
+                           sizeof(SchRrmPolicyRatio));
                   break;
                }
             }
@@ -1941,7 +1958,7 @@ void SchSendSliceReCfgRspToMac(Inst inst, SchSliceCfgRsp schSliceReCfgRsp)
 uint8_t MacSchSliceReCfgReq(Pst *pst, SchSliceCfgReq *schSliceReCfgReq)
 {
    uint8_t count = 0;
-   Inst   inst = pst->dstInst - 1;
+   Inst   inst = pst->dstInst - SCH_INST_START;
    SchSliceCfgRsp schSliceReCfgRsp;
 
    DU_LOG("\nINFO  -->  SCH : Received Slice ReCfg request from MAC");
@@ -1972,6 +1989,118 @@ uint8_t MacSchSliceReCfgReq(Pst *pst, SchSliceCfgReq *schSliceReCfgReq)
    return ROK;
 }
 
+/****************************************************************************
+ *
+ * @brief Stores the Paging Configuration from DU APP in CellCb 
+ *
+ * @details
+ *
+ *    Function : schProcPagingParam
+ *
+ *    Functionality:
+ *          Process the Paging Configuration when FirstPDCCHMonitoring for
+ *          Paging Ocassion is not present.
+ *
+ *          As per 38.304 Sec 7.1,
+ *          "When firstPDCCH-MonitoringOccasionOfPO is present, the
+ *          starting PDCCH monitoring occasion number of (i_s + 1)th PO is the
+ *          (i_s + 1)th value of the firstPDCCHMonitoringOccasionOfPO
+ *          parameter; otherwise, it is equal to i_s * S."
+ *          "S = number of actual transmitted SSBs determined according 
+ *              to ssb-PositionsInBurst in SIB1"
+ *
+ * @params[in] SchCellCb *cell 
+ *       
+ * @return void 
+ *        
+ *************************************************************************/
+void schProcPagingCfg(SchCellCb *cell)
+{
+   PageCfg *pageCfgRcvd = NULL;
+   uint8_t i_sIdx = 0;
+
+   pageCfgRcvd = &(cell->cellCfg.sib1SchCfg.pageCfg);
+
+   if(pageCfgRcvd->poPresent == TRUE)
+   {
+      /*Fetching first Pdcch Monitoring Occasion for SFN (i_s + 1)th*/
+      for(i_sIdx = 0; i_sIdx < pageCfgRcvd->numPO; i_sIdx++)
+      {
+         cell->pageCb.pagMonOcc[i_sIdx].pagingOccSlot = pageCfgRcvd->pagingOcc[i_sIdx] / MAX_SYMB_PER_SLOT ;
+         if ((pageCfgRcvd->pagingOcc[i_sIdx] % MAX_SYMB_PER_SLOT) != 0 )
+         {
+            cell->pageCb.pagMonOcc[i_sIdx].pagingOccSlot++;
+         }
+
+         cell->pageCb.pagMonOcc[i_sIdx].frameOffset = 0;
+
+      }
+   }
+   else
+   {
+      schCfgPdcchMonOccOfPO(cell);                  
+   }
+}
+
+/****************************************************************************
+ *
+ * @brief Calculate PO if not present in Configuration 
+ *
+ * @details
+ *
+ *    Function : schCfgPdcchMonOccOfPO
+ *
+ *    Functionality: In this function, PO are calculated i_s * S because
+ *    FirstPDCCHMonitoring_ForPO is not present.
+ *
+ * @params[in] SchCellCb *cellCb
+ *       
+ * @return void 
+ *        
+ *************************************************************************/
+void schCfgPdcchMonOccOfPO(SchCellCb *cell)
+{
+   uint8_t         cnt = 0, incr = 1, i_sIdx = 0, frameOffSet = 0;
+   uint8_t         nsValue = cell->cellCfg.sib1SchCfg.pageCfg.numPO;
+   uint8_t         totalNumSsb = cell->cellCfg.ssbSchCfg.totNumSsb;
+   SlotTimingInfo  tmpTimingInfo, pdcchTime; 
+
+   /*Starting with First Sfn and slot*/
+   tmpTimingInfo.sfn = 0;
+   tmpTimingInfo.slot = 0;
+
+   pdcchTime = tmpTimingInfo;
+
+   while(i_sIdx < nsValue)
+   {
+      /*Increment frame Offset if PO falls on next SFN*/
+      if(pdcchTime.sfn != tmpTimingInfo.sfn)
+      {
+         frameOffSet++;
+      }
+      pdcchTime = tmpTimingInfo;
+      schIncrSlot(&(tmpTimingInfo), incr, cell->numSlots);
+
+      if (i_sIdx == 0)
+      {
+         cell->pageCb.pagMonOcc[i_sIdx].pagingOccSlot = pdcchTime.slot;
+         cell->pageCb.pagMonOcc[i_sIdx].frameOffset = frameOffSet;
+         i_sIdx++;
+      }
+      else
+      {
+         cnt++;
+         if((cnt == totalNumSsb) && (i_sIdx < MAX_PO_PER_PF)) 
+         {
+            cell->pageCb.pagMonOcc[i_sIdx].pagingOccSlot = pdcchTime.slot;
+            cell->pageCb.pagMonOcc[i_sIdx].frameOffset = frameOffSet;
+            cnt = 0;
+            i_sIdx++;
+         }
+      }
+   }
+}
+
 /**********************************************************************
   End of file
  **********************************************************************/